3 Copyright 1993, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 OTHER DEALINGS IN THE SOFTWARE.
22 Except as contained in this notice, the name of The Open Group shall
23 not be used in advertising or otherwise to promote the sale, use or
24 other dealings in this Software without prior written authorization
29 #ifdef HAVE_XWIN_CONFIG_H
30 #include <xwin-config.h>
33 #define VENDOR_STRING XVENDORNAME
34 #define VERSION_STRING XORG_RELEASE
35 #define VENDOR_CONTACT BUILDERADDR
38 #include "winconfig.h"
43 * References to external symbols
46 extern int g_iNumScreens
;
47 extern winScreenInfo g_ScreenInfo
[];
48 extern int g_iLastScreen
;
49 extern Bool g_fInitializedDefaultScreens
;
51 extern Bool g_fUnicodeClipboard
;
52 extern Bool g_fClipboard
;
54 extern int g_iLogVerbose
;
55 extern char * g_pszLogFile
;
56 #ifdef RELOCATE_PROJECTROOT
57 extern Bool g_fLogFileChanged
;
59 extern Bool g_fXdmcpEnabled
;
60 extern char * g_pszCommandLine
;
61 extern Bool g_fKeyboardHookLL
;
62 extern Bool g_fNoHelpMessageBox
;
63 extern Bool g_fSoftwareCursor
;
64 extern Bool g_fSilentDupError
;
66 /* globals required by callback function for monitor information */
67 struct GetMonitorInfoData
{
70 Bool bUserSpecifiedMonitor
;
71 Bool bMonitorSpecifiedExists
;
78 typedef wBOOL (*ENUMDISPLAYMONITORSPROC
)(HDC
,LPCRECT
,MONITORENUMPROC
,LPARAM
);
79 ENUMDISPLAYMONITORSPROC _EnumDisplayMonitors
;
81 wBOOL CALLBACK
getMonitorInfo(HMONITOR hMonitor
, HDC hdc
, LPRECT rect
, LPARAM _data
);
83 static Bool
QueryMonitor(int index
, struct GetMonitorInfoData
*data
)
85 /* Load EnumDisplayMonitors from DLL */
88 user32
= LoadLibrary("user32.dll");
91 winW32Error(2, "Could not open user32.dll");
94 func
= GetProcAddress(user32
, "EnumDisplayMonitors");
97 winW32Error(2, "Could not resolve EnumDisplayMonitors: ");
100 _EnumDisplayMonitors
= (ENUMDISPLAYMONITORSPROC
)func
;
105 memset(data
, 0, sizeof(*data
));
106 data
->requestedMonitor
= index
;
108 /* query information */
109 _EnumDisplayMonitors(NULL
, NULL
, getMonitorInfo
, (LPARAM
) data
);
117 * Function prototypes
121 winLogCommandLine (int argc
, char *argv
[]);
124 winLogVersionInfo (void);
127 void OsVendorVErrorF (const char *pszFormat
, va_list va_args
);
131 winInitializeDefaultScreens (void);
134 * Process arguments on the command line
138 winInitializeDefaultScreens (void)
141 DWORD dwWidth
, dwHeight
;
143 /* Bail out early if default screens have already been initialized */
144 if (g_fInitializedDefaultScreens
)
147 /* Zero the memory used for storing the screen info */
148 ZeroMemory (g_ScreenInfo
, MAXSCREENS
* sizeof (winScreenInfo
));
150 /* Get default width and height */
152 * NOTE: These defaults will cause the window to cover only
153 * the primary monitor in the case that we have multiple monitors.
155 dwWidth
= GetSystemMetrics (SM_CXSCREEN
);
156 dwHeight
= GetSystemMetrics (SM_CYSCREEN
);
158 winErrorFVerb (2, "winInitializeDefaultScreens - w %d h %d\n",
159 (int) dwWidth
, (int) dwHeight
);
161 /* Set a default DPI, if no parameter was passed */
162 if (monitorResolution
== 0)
163 monitorResolution
= WIN_DEFAULT_DPI
;
165 for (i
= 0; i
< MAXSCREENS
; ++i
)
167 g_ScreenInfo
[i
].dwScreen
= i
;
168 g_ScreenInfo
[i
].dwWidth
= dwWidth
;
169 g_ScreenInfo
[i
].dwHeight
= dwHeight
;
170 g_ScreenInfo
[i
].dwUserWidth
= dwWidth
;
171 g_ScreenInfo
[i
].dwUserHeight
= dwHeight
;
172 g_ScreenInfo
[i
].fUserGaveHeightAndWidth
173 = WIN_DEFAULT_USER_GAVE_HEIGHT_AND_WIDTH
;
174 g_ScreenInfo
[i
].fUserGavePosition
= FALSE
;
175 g_ScreenInfo
[i
].dwBPP
= WIN_DEFAULT_BPP
;
176 g_ScreenInfo
[i
].dwClipUpdatesNBoxes
= WIN_DEFAULT_CLIP_UPDATES_NBOXES
;
177 #ifdef XWIN_EMULATEPSEUDO
178 g_ScreenInfo
[i
].fEmulatePseudo
= WIN_DEFAULT_EMULATE_PSEUDO
;
180 g_ScreenInfo
[i
].dwRefreshRate
= WIN_DEFAULT_REFRESH
;
181 g_ScreenInfo
[i
].pfb
= NULL
;
182 g_ScreenInfo
[i
].fFullScreen
= FALSE
;
183 g_ScreenInfo
[i
].fDecoration
= TRUE
;
184 #ifdef XWIN_MULTIWINDOWEXTWM
185 g_ScreenInfo
[i
].fMWExtWM
= FALSE
;
186 g_ScreenInfo
[i
].fInternalWM
= FALSE
;
188 g_ScreenInfo
[i
].fRootless
= FALSE
;
189 #ifdef XWIN_MULTIWINDOW
190 g_ScreenInfo
[i
].fMultiWindow
= FALSE
;
192 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
193 g_ScreenInfo
[i
].fMultiMonitorOverride
= FALSE
;
195 g_ScreenInfo
[i
].fMultipleMonitors
= FALSE
;
196 g_ScreenInfo
[i
].fLessPointer
= FALSE
;
197 g_ScreenInfo
[i
].fScrollbars
= FALSE
;
198 g_ScreenInfo
[i
].fNoTrayIcon
= FALSE
;
199 g_ScreenInfo
[i
].iE3BTimeout
= WIN_E3B_OFF
;
200 g_ScreenInfo
[i
].dwWidth_mm
= (dwWidth
/ WIN_DEFAULT_DPI
)
202 g_ScreenInfo
[i
].dwHeight_mm
= (dwHeight
/ WIN_DEFAULT_DPI
)
204 g_ScreenInfo
[i
].fUseWinKillKey
= WIN_DEFAULT_WIN_KILL
;
205 g_ScreenInfo
[i
].fUseUnixKillKey
= WIN_DEFAULT_UNIX_KILL
;
206 g_ScreenInfo
[i
].fIgnoreInput
= FALSE
;
207 g_ScreenInfo
[i
].fExplicitScreen
= FALSE
;
210 /* Signal that the default screens have been initialized */
211 g_fInitializedDefaultScreens
= TRUE
;
213 winErrorFVerb (2, "winInitializeDefaultScreens - Returning\n");
216 /* See Porting Layer Definition - p. 57 */
219 * argv: pointer to an array of null-terminated strings, one for
220 * each token in the X Server command line; the first token
221 * is 'XWin.exe', or similar.
222 * argc: a count of the number of tokens stored in argv.
223 * i: a zero-based index into argv indicating the current token being
227 * return: return the number of tokens processed correctly.
230 * When looking for n tokens, check that i + n is less than argc. Or,
231 * you may check if i is greater than or equal to argc, in which case
232 * you should display the UseMsg () and return 0.
235 /* Check if enough arguments are given for the option */
236 #define CHECK_ARGS(count) if (i + count >= argc) { UseMsg (); return 0; }
238 /* Compare the current option with the string. */
239 #define IS_OPTION(name) (strcmp (argv[i], name) == 0)
242 ddxProcessArgument (int argc
, char *argv
[], int i
)
244 static Bool s_fBeenHere
= FALSE
;
246 /* Initialize once */
251 * This initialises our hook into VErrorF () for catching log messages
252 * that are generated before OsInit () is called.
254 OsVendorVErrorFProc
= OsVendorVErrorF
;
259 /* Initialize only if option is not -help */
260 if (!IS_OPTION("-help") && !IS_OPTION("-h") && !IS_OPTION("--help") &&
261 !IS_OPTION("-version") && !IS_OPTION("--version"))
264 /* Log the version information */
265 winLogVersionInfo ();
267 /* Log the command line */
268 winLogCommandLine (argc
, argv
);
271 * Initialize default screen settings. We have to do this before
272 * OsVendorInit () gets called, otherwise we will overwrite
273 * settings changed by parameters such as -fullscreen, etc.
275 winErrorFVerb (2, "ddxProcessArgument - Initializing default "
277 winInitializeDefaultScreens ();
282 winDebug ("ddxProcessArgument - arg: %s\n", argv
[i
]);
286 * Look for the '-help' and similar options
288 if (IS_OPTION ("-help") || IS_OPTION("-h") || IS_OPTION("--help"))
290 /* Reset logfile. We don't need that helpmessage in the logfile */
292 g_fNoHelpMessageBox
= TRUE
;
298 if (IS_OPTION ("-version") || IS_OPTION("--version"))
300 /* Reset logfile. We don't need that versioninfo in the logfile */
302 winLogVersionInfo ();
308 * Look for the '-screen scr_num [width height]' argument
310 if (IS_OPTION ("-screen"))
312 int iArgsProcessed
= 1;
314 int iWidth
, iHeight
, iX
, iY
;
318 winDebug ("ddxProcessArgument - screen - argc: %d i: %d\n",
322 /* Display the usage message if the argument is malformed */
328 /* Grab screen number */
329 nScreenNum
= atoi (argv
[i
+ 1]);
331 /* Validate the specified screen number */
332 if (nScreenNum
< 0 || nScreenNum
>= MAXSCREENS
)
334 ErrorF ("ddxProcessArgument - screen - Invalid screen number %d\n",
340 /* look for @m where m is monitor number */
342 && 1 == sscanf(argv
[i
+ 2], "@%d", (int *) &iMonitor
))
344 struct GetMonitorInfoData data
;
345 if (!QueryMonitor(iMonitor
, &data
))
347 ErrorF ("ddxProcessArgument - screen - "
348 "Querying monitors is not supported on NT4 and Win95\n");
349 } else if (data
.bMonitorSpecifiedExists
== TRUE
)
351 winErrorFVerb(2, "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor
);
353 g_ScreenInfo
[nScreenNum
].fUserGaveHeightAndWidth
= FALSE
;
354 g_ScreenInfo
[nScreenNum
].fUserGavePosition
= TRUE
;
355 g_ScreenInfo
[nScreenNum
].dwWidth
= data
.monitorWidth
;
356 g_ScreenInfo
[nScreenNum
].dwHeight
= data
.monitorHeight
;
357 g_ScreenInfo
[nScreenNum
].dwUserWidth
= data
.monitorWidth
;
358 g_ScreenInfo
[nScreenNum
].dwUserHeight
= data
.monitorHeight
;
359 g_ScreenInfo
[nScreenNum
].dwInitialX
= data
.monitorOffsetX
;
360 g_ScreenInfo
[nScreenNum
].dwInitialY
= data
.monitorOffsetY
;
364 /* monitor does not exist, error out */
365 ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n",
373 /* Look for 'WxD' or 'W D' */
374 else if (i
+ 2 < argc
375 && 2 == sscanf (argv
[i
+ 2], "%dx%d",
379 winErrorFVerb (2, "ddxProcessArgument - screen - Found ``WxD'' arg\n");
381 g_ScreenInfo
[nScreenNum
].fUserGaveHeightAndWidth
= TRUE
;
382 g_ScreenInfo
[nScreenNum
].dwWidth
= iWidth
;
383 g_ScreenInfo
[nScreenNum
].dwHeight
= iHeight
;
384 g_ScreenInfo
[nScreenNum
].dwUserWidth
= iWidth
;
385 g_ScreenInfo
[nScreenNum
].dwUserHeight
= iHeight
;
386 /* Look for WxD+X+Y */
387 if (2 == sscanf (argv
[i
+ 2], "%*dx%*d+%d+%d",
391 winErrorFVerb (2, "ddxProcessArgument - screen - Found ``X+Y'' arg\n");
392 g_ScreenInfo
[nScreenNum
].fUserGavePosition
= TRUE
;
393 g_ScreenInfo
[nScreenNum
].dwInitialX
= iX
;
394 g_ScreenInfo
[nScreenNum
].dwInitialY
= iY
;
396 /* look for WxD+X+Y@m where m is monitor number. take X,Y to be offsets from monitor's root position */
397 if (1 == sscanf (argv
[i
+ 2], "%*dx%*d+%*d+%*d@%d",
400 struct GetMonitorInfoData data
;
401 if (!QueryMonitor(iMonitor
, &data
))
403 ErrorF ("ddxProcessArgument - screen - "
404 "Querying monitors is not supported on NT4 and Win95\n");
405 } else if (data
.bMonitorSpecifiedExists
== TRUE
)
407 g_ScreenInfo
[nScreenNum
].dwInitialX
+= data
.monitorOffsetX
;
408 g_ScreenInfo
[nScreenNum
].dwInitialY
+= data
.monitorOffsetY
;
412 /* monitor does not exist, error out */
413 ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n",
423 /* look for WxD@m where m is monitor number */
424 else if (1 == sscanf(argv
[i
+ 2], "%*dx%*d@%d",
427 struct GetMonitorInfoData data
;
428 if (!QueryMonitor(iMonitor
, &data
))
430 ErrorF ("ddxProcessArgument - screen - "
431 "Querying monitors is not supported on NT4 and Win95\n");
432 } else if (data
.bMonitorSpecifiedExists
== TRUE
)
434 winErrorFVerb (2, "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor
);
435 g_ScreenInfo
[nScreenNum
].fUserGavePosition
= TRUE
;
436 g_ScreenInfo
[nScreenNum
].dwInitialX
= data
.monitorOffsetX
;
437 g_ScreenInfo
[nScreenNum
].dwInitialY
= data
.monitorOffsetY
;
441 /* monitor does not exist, error out */
442 ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n",
451 else if (i
+ 3 < argc
452 && 1 == sscanf (argv
[i
+ 2], "%d",
454 && 1 == sscanf (argv
[i
+ 3], "%d",
457 winErrorFVerb (2, "ddxProcessArgument - screen - Found ``W D'' arg\n");
459 g_ScreenInfo
[nScreenNum
].fUserGaveHeightAndWidth
= TRUE
;
460 g_ScreenInfo
[nScreenNum
].dwWidth
= iWidth
;
461 g_ScreenInfo
[nScreenNum
].dwHeight
= iHeight
;
462 g_ScreenInfo
[nScreenNum
].dwUserWidth
= iWidth
;
463 g_ScreenInfo
[nScreenNum
].dwUserHeight
= iHeight
;
465 && 1 == sscanf (argv
[i
+ 4], "%d",
467 && 1 == sscanf (argv
[i
+ 5], "%d",
470 winErrorFVerb (2, "ddxProcessArgument - screen - Found ``X Y'' arg\n");
472 g_ScreenInfo
[nScreenNum
].fUserGavePosition
= TRUE
;
473 g_ScreenInfo
[nScreenNum
].dwInitialX
= iX
;
474 g_ScreenInfo
[nScreenNum
].dwInitialY
= iY
;
479 winErrorFVerb (2, "ddxProcessArgument - screen - Did not find size arg. "
480 "dwWidth: %d dwHeight: %d\n",
481 (int) g_ScreenInfo
[nScreenNum
].dwWidth
,
482 (int) g_ScreenInfo
[nScreenNum
].dwHeight
);
484 g_ScreenInfo
[nScreenNum
].fUserGaveHeightAndWidth
= FALSE
;
487 /* Calculate the screen width and height in millimeters */
488 if (g_ScreenInfo
[nScreenNum
].fUserGaveHeightAndWidth
)
490 g_ScreenInfo
[nScreenNum
].dwWidth_mm
491 = (g_ScreenInfo
[nScreenNum
].dwWidth
492 / monitorResolution
) * 25.4;
493 g_ScreenInfo
[nScreenNum
].dwHeight_mm
494 = (g_ScreenInfo
[nScreenNum
].dwHeight
495 / monitorResolution
) * 25.4;
498 /* Flag that this screen was explicity specified by the user */
499 g_ScreenInfo
[nScreenNum
].fExplicitScreen
= TRUE
;
502 * Keep track of the last screen number seen, as parameters seen
503 * before a screen number apply to all screens, whereas parameters
504 * seen after a screen number apply to that screen number only.
506 g_iLastScreen
= nScreenNum
;
508 /* Keep a count of the number of screens */
511 return iArgsProcessed
;
515 * Look for the '-engine n' argument
517 if (IS_OPTION ("-engine"))
522 /* Display the usage message if the argument is malformed */
529 /* Grab the argument */
530 dwEngine
= atoi (argv
[i
]);
532 /* Count the one bits in the engine argument */
533 c8OnBits
= winCountBits (dwEngine
);
535 /* Argument should only have a single bit on */
542 /* Is this parameter attached to a screen or global? */
543 if (-1 == g_iLastScreen
)
547 /* Parameter is for all screens */
548 for (j
= 0; j
< MAXSCREENS
; j
++)
550 g_ScreenInfo
[j
].dwEnginePreferred
= dwEngine
;
555 /* Parameter is for a single screen */
556 g_ScreenInfo
[g_iLastScreen
].dwEnginePreferred
= dwEngine
;
559 /* Indicate that we have processed the argument */
564 * Look for the '-fullscreen' argument
566 if (IS_OPTION ("-fullscreen"))
568 /* Is this parameter attached to a screen or is it global? */
569 if (-1 == g_iLastScreen
)
573 /* Parameter is for all screens */
574 for (j
= 0; j
< MAXSCREENS
; j
++)
576 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
577 if (!g_ScreenInfo
[j
].fMultiMonitorOverride
)
578 g_ScreenInfo
[j
].fMultipleMonitors
= FALSE
;
580 g_ScreenInfo
[j
].fFullScreen
= TRUE
;
585 /* Parameter is for a single screen */
586 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
587 if (!g_ScreenInfo
[g_iLastScreen
].fMultiMonitorOverride
)
588 g_ScreenInfo
[g_iLastScreen
].fMultipleMonitors
= FALSE
;
590 g_ScreenInfo
[g_iLastScreen
].fFullScreen
= TRUE
;
593 /* Indicate that we have processed this argument */
598 * Look for the '-lesspointer' argument
600 if (IS_OPTION ("-lesspointer"))
602 /* Is this parameter attached to a screen or is it global? */
603 if (-1 == g_iLastScreen
)
607 /* Parameter is for all screens */
608 for (j
= 0; j
< MAXSCREENS
; j
++)
610 g_ScreenInfo
[j
].fLessPointer
= TRUE
;
615 /* Parameter is for a single screen */
616 g_ScreenInfo
[g_iLastScreen
].fLessPointer
= TRUE
;
619 /* Indicate that we have processed this argument */
624 * Look for the '-nodecoration' argument
626 if (IS_OPTION ("-nodecoration"))
628 /* Is this parameter attached to a screen or is it global? */
629 if (-1 == g_iLastScreen
)
633 /* Parameter is for all screens */
634 for (j
= 0; j
< MAXSCREENS
; j
++)
636 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
637 if (!g_ScreenInfo
[j
].fMultiMonitorOverride
)
638 g_ScreenInfo
[j
].fMultipleMonitors
= FALSE
;
640 g_ScreenInfo
[j
].fDecoration
= FALSE
;
645 /* Parameter is for a single screen */
646 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
647 if (!g_ScreenInfo
[g_iLastScreen
].fMultiMonitorOverride
)
648 g_ScreenInfo
[g_iLastScreen
].fMultipleMonitors
= FALSE
;
650 g_ScreenInfo
[g_iLastScreen
].fDecoration
= FALSE
;
653 /* Indicate that we have processed this argument */
657 #ifdef XWIN_MULTIWINDOWEXTWM
659 * Look for the '-mwextwm' argument
661 if (IS_OPTION ("-mwextwm"))
663 /* Is this parameter attached to a screen or is it global? */
664 if (-1 == g_iLastScreen
)
668 /* Parameter is for all screens */
669 for (j
= 0; j
< MAXSCREENS
; j
++)
671 if (!g_ScreenInfo
[j
].fMultiMonitorOverride
)
672 g_ScreenInfo
[j
].fMultipleMonitors
= TRUE
;
673 g_ScreenInfo
[j
].fMWExtWM
= TRUE
;
678 /* Parameter is for a single screen */
679 if (!g_ScreenInfo
[g_iLastScreen
].fMultiMonitorOverride
)
680 g_ScreenInfo
[g_iLastScreen
].fMultipleMonitors
= TRUE
;
681 g_ScreenInfo
[g_iLastScreen
].fMWExtWM
= TRUE
;
684 /* Indicate that we have processed this argument */
688 * Look for the '-internalwm' argument
690 if (IS_OPTION ("-internalwm"))
692 /* Is this parameter attached to a screen or is it global? */
693 if (-1 == g_iLastScreen
)
697 /* Parameter is for all screens */
698 for (j
= 0; j
< MAXSCREENS
; j
++)
700 if (!g_ScreenInfo
[j
].fMultiMonitorOverride
)
701 g_ScreenInfo
[j
].fMultipleMonitors
= TRUE
;
702 g_ScreenInfo
[j
].fMWExtWM
= TRUE
;
703 g_ScreenInfo
[j
].fInternalWM
= TRUE
;
708 /* Parameter is for a single screen */
709 if (!g_ScreenInfo
[g_iLastScreen
].fMultiMonitorOverride
)
710 g_ScreenInfo
[g_iLastScreen
].fMultipleMonitors
= TRUE
;
711 g_ScreenInfo
[g_iLastScreen
].fMWExtWM
= TRUE
;
712 g_ScreenInfo
[g_iLastScreen
].fInternalWM
= TRUE
;
715 /* Indicate that we have processed this argument */
721 * Look for the '-rootless' argument
723 if (IS_OPTION ("-rootless"))
725 /* Is this parameter attached to a screen or is it global? */
726 if (-1 == g_iLastScreen
)
730 /* Parameter is for all screens */
731 for (j
= 0; j
< MAXSCREENS
; j
++)
733 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
734 if (!g_ScreenInfo
[j
].fMultiMonitorOverride
)
735 g_ScreenInfo
[j
].fMultipleMonitors
= FALSE
;
737 g_ScreenInfo
[j
].fRootless
= TRUE
;
742 /* Parameter is for a single screen */
743 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
744 if (!g_ScreenInfo
[g_iLastScreen
].fMultiMonitorOverride
)
745 g_ScreenInfo
[g_iLastScreen
].fMultipleMonitors
= FALSE
;
747 g_ScreenInfo
[g_iLastScreen
].fRootless
= TRUE
;
750 /* Indicate that we have processed this argument */
754 #ifdef XWIN_MULTIWINDOW
756 * Look for the '-multiwindow' argument
758 if (IS_OPTION ("-multiwindow"))
760 /* Is this parameter attached to a screen or is it global? */
761 if (-1 == g_iLastScreen
)
765 /* Parameter is for all screens */
766 for (j
= 0; j
< MAXSCREENS
; j
++)
768 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
769 if (!g_ScreenInfo
[j
].fMultiMonitorOverride
)
770 g_ScreenInfo
[j
].fMultipleMonitors
= TRUE
;
772 g_ScreenInfo
[j
].fMultiWindow
= TRUE
;
777 /* Parameter is for a single screen */
778 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
779 if (!g_ScreenInfo
[g_iLastScreen
].fMultiMonitorOverride
)
780 g_ScreenInfo
[g_iLastScreen
].fMultipleMonitors
= TRUE
;
782 g_ScreenInfo
[g_iLastScreen
].fMultiWindow
= TRUE
;
785 /* Indicate that we have processed this argument */
791 * Look for the '-multiplemonitors' argument
793 if (IS_OPTION ("-multiplemonitors")
794 || IS_OPTION ("-multimonitors"))
796 /* Is this parameter attached to a screen or is it global? */
797 if (-1 == g_iLastScreen
)
801 /* Parameter is for all screens */
802 for (j
= 0; j
< MAXSCREENS
; j
++)
804 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
805 g_ScreenInfo
[j
].fMultiMonitorOverride
= TRUE
;
807 g_ScreenInfo
[j
].fMultipleMonitors
= TRUE
;
812 /* Parameter is for a single screen */
813 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
814 g_ScreenInfo
[g_iLastScreen
].fMultiMonitorOverride
= TRUE
;
816 g_ScreenInfo
[g_iLastScreen
].fMultipleMonitors
= TRUE
;
819 /* Indicate that we have processed this argument */
824 * Look for the '-nomultiplemonitors' argument
826 if (IS_OPTION ("-nomultiplemonitors")
827 || IS_OPTION ("-nomultimonitors"))
829 /* Is this parameter attached to a screen or is it global? */
830 if (-1 == g_iLastScreen
)
834 /* Parameter is for all screens */
835 for (j
= 0; j
< MAXSCREENS
; j
++)
837 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
838 g_ScreenInfo
[j
].fMultiMonitorOverride
= TRUE
;
840 g_ScreenInfo
[j
].fMultipleMonitors
= FALSE
;
845 /* Parameter is for a single screen */
846 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
847 g_ScreenInfo
[g_iLastScreen
].fMultiMonitorOverride
= TRUE
;
849 g_ScreenInfo
[g_iLastScreen
].fMultipleMonitors
= FALSE
;
852 /* Indicate that we have processed this argument */
858 * Look for the '-scrollbars' argument
860 if (IS_OPTION ("-scrollbars"))
862 /* Is this parameter attached to a screen or is it global? */
863 if (-1 == g_iLastScreen
)
867 /* Parameter is for all screens */
868 for (j
= 0; j
< MAXSCREENS
; j
++)
870 g_ScreenInfo
[j
].fScrollbars
= TRUE
;
875 /* Parameter is for a single screen */
876 g_ScreenInfo
[g_iLastScreen
].fScrollbars
= TRUE
;
879 /* Indicate that we have processed this argument */
884 #ifdef XWIN_CLIPBOARD
886 * Look for the '-clipboard' argument
888 if (IS_OPTION ("-clipboard"))
892 /* Indicate that we have processed this argument */
899 * Look for the '-ignoreinput' argument
901 if (IS_OPTION ("-ignoreinput"))
903 /* Is this parameter attached to a screen or is it global? */
904 if (-1 == g_iLastScreen
)
908 /* Parameter is for all screens */
909 for (j
= 0; j
< MAXSCREENS
; j
++)
911 g_ScreenInfo
[j
].fIgnoreInput
= TRUE
;
916 /* Parameter is for a single screen */
917 g_ScreenInfo
[g_iLastScreen
].fIgnoreInput
= TRUE
;
920 /* Indicate that we have processed this argument */
925 * Look for the '-emulate3buttons' argument
927 if (IS_OPTION ("-emulate3buttons"))
929 int iArgsProcessed
= 1;
930 int iE3BTimeout
= WIN_DEFAULT_E3B_TIME
;
932 /* Grab the optional timeout value */
934 && 1 == sscanf (argv
[i
+ 1], "%d",
937 /* Indicate that we have processed the next argument */
943 * sscanf () won't modify iE3BTimeout if it doesn't find
944 * the specified format; however, I want to be explicit
945 * about setting the default timeout in such cases to
946 * prevent some programs (me) from getting confused.
948 iE3BTimeout
= WIN_DEFAULT_E3B_TIME
;
951 /* Is this parameter attached to a screen or is it global? */
952 if (-1 == g_iLastScreen
)
956 /* Parameter is for all screens */
957 for (j
= 0; j
< MAXSCREENS
; j
++)
959 g_ScreenInfo
[j
].iE3BTimeout
= iE3BTimeout
;
964 /* Parameter is for a single screen */
965 g_ScreenInfo
[g_iLastScreen
].iE3BTimeout
= iE3BTimeout
;
968 /* Indicate that we have processed this argument */
969 return iArgsProcessed
;
973 * Look for the '-depth n' argument
975 if (IS_OPTION ("-depth"))
979 /* Display the usage message if the argument is malformed */
986 /* Grab the argument */
987 dwBPP
= atoi (argv
[i
]);
989 /* Is this parameter attached to a screen or global? */
990 if (-1 == g_iLastScreen
)
994 /* Parameter is for all screens */
995 for (j
= 0; j
< MAXSCREENS
; j
++)
997 g_ScreenInfo
[j
].dwBPP
= dwBPP
;
1002 /* Parameter is for a single screen */
1003 g_ScreenInfo
[g_iLastScreen
].dwBPP
= dwBPP
;
1006 /* Indicate that we have processed the argument */
1011 * Look for the '-refresh n' argument
1013 if (IS_OPTION ("-refresh"))
1015 DWORD dwRefreshRate
= 0;
1017 /* Display the usage message if the argument is malformed */
1024 /* Grab the argument */
1025 dwRefreshRate
= atoi (argv
[i
]);
1027 /* Is this parameter attached to a screen or global? */
1028 if (-1 == g_iLastScreen
)
1032 /* Parameter is for all screens */
1033 for (j
= 0; j
< MAXSCREENS
; j
++)
1035 g_ScreenInfo
[j
].dwRefreshRate
= dwRefreshRate
;
1040 /* Parameter is for a single screen */
1041 g_ScreenInfo
[g_iLastScreen
].dwRefreshRate
= dwRefreshRate
;
1044 /* Indicate that we have processed the argument */
1049 * Look for the '-clipupdates num_boxes' argument
1051 if (IS_OPTION ("-clipupdates"))
1053 DWORD dwNumBoxes
= 0;
1055 /* Display the usage message if the argument is malformed */
1062 /* Grab the argument */
1063 dwNumBoxes
= atoi (argv
[i
]);
1065 /* Is this parameter attached to a screen or global? */
1066 if (-1 == g_iLastScreen
)
1070 /* Parameter is for all screens */
1071 for (j
= 0; j
< MAXSCREENS
; j
++)
1073 g_ScreenInfo
[j
].dwClipUpdatesNBoxes
= dwNumBoxes
;
1078 /* Parameter is for a single screen */
1079 g_ScreenInfo
[g_iLastScreen
].dwClipUpdatesNBoxes
= dwNumBoxes
;
1082 /* Indicate that we have processed the argument */
1086 #ifdef XWIN_EMULATEPSEUDO
1088 * Look for the '-emulatepseudo' argument
1090 if (IS_OPTION ("-emulatepseudo"))
1092 /* Is this parameter attached to a screen or is it global? */
1093 if (-1 == g_iLastScreen
)
1097 /* Parameter is for all screens */
1098 for (j
= 0; j
< MAXSCREENS
; j
++)
1100 g_ScreenInfo
[j
].fEmulatePseudo
= TRUE
;
1105 /* Parameter is for a single screen */
1106 g_ScreenInfo
[g_iLastScreen
].fEmulatePseudo
= TRUE
;
1109 /* Indicate that we have processed this argument */
1115 * Look for the '-nowinkill' argument
1117 if (IS_OPTION ("-nowinkill"))
1119 /* Is this parameter attached to a screen or is it global? */
1120 if (-1 == g_iLastScreen
)
1124 /* Parameter is for all screens */
1125 for (j
= 0; j
< MAXSCREENS
; j
++)
1127 g_ScreenInfo
[j
].fUseWinKillKey
= FALSE
;
1132 /* Parameter is for a single screen */
1133 g_ScreenInfo
[g_iLastScreen
].fUseWinKillKey
= FALSE
;
1136 /* Indicate that we have processed this argument */
1141 * Look for the '-winkill' argument
1143 if (IS_OPTION ("-winkill"))
1145 /* Is this parameter attached to a screen or is it global? */
1146 if (-1 == g_iLastScreen
)
1150 /* Parameter is for all screens */
1151 for (j
= 0; j
< MAXSCREENS
; j
++)
1153 g_ScreenInfo
[j
].fUseWinKillKey
= TRUE
;
1158 /* Parameter is for a single screen */
1159 g_ScreenInfo
[g_iLastScreen
].fUseWinKillKey
= TRUE
;
1162 /* Indicate that we have processed this argument */
1167 * Look for the '-nounixkill' argument
1169 if (IS_OPTION ("-nounixkill"))
1171 /* Is this parameter attached to a screen or is it global? */
1172 if (-1 == g_iLastScreen
)
1176 /* Parameter is for all screens */
1177 for (j
= 0; j
< MAXSCREENS
; j
++)
1179 g_ScreenInfo
[j
].fUseUnixKillKey
= FALSE
;
1184 /* Parameter is for a single screen */
1185 g_ScreenInfo
[g_iLastScreen
].fUseUnixKillKey
= FALSE
;
1188 /* Indicate that we have processed this argument */
1193 * Look for the '-unixkill' argument
1195 if (IS_OPTION ("-unixkill"))
1197 /* Is this parameter attached to a screen or is it global? */
1198 if (-1 == g_iLastScreen
)
1202 /* Parameter is for all screens */
1203 for (j
= 0; j
< MAXSCREENS
; j
++)
1205 g_ScreenInfo
[j
].fUseUnixKillKey
= TRUE
;
1210 /* Parameter is for a single screen */
1211 g_ScreenInfo
[g_iLastScreen
].fUseUnixKillKey
= TRUE
;
1214 /* Indicate that we have processed this argument */
1219 * Look for the '-notrayicon' argument
1221 if (IS_OPTION ("-notrayicon"))
1223 /* Is this parameter attached to a screen or is it global? */
1224 if (-1 == g_iLastScreen
)
1228 /* Parameter is for all screens */
1229 for (j
= 0; j
< MAXSCREENS
; j
++)
1231 g_ScreenInfo
[j
].fNoTrayIcon
= TRUE
;
1236 /* Parameter is for a single screen */
1237 g_ScreenInfo
[g_iLastScreen
].fNoTrayIcon
= TRUE
;
1240 /* Indicate that we have processed this argument */
1245 * Look for the '-trayicon' argument
1247 if (IS_OPTION ("-trayicon"))
1249 /* Is this parameter attached to a screen or is it global? */
1250 if (-1 == g_iLastScreen
)
1254 /* Parameter is for all screens */
1255 for (j
= 0; j
< MAXSCREENS
; j
++)
1257 g_ScreenInfo
[j
].fNoTrayIcon
= FALSE
;
1262 /* Parameter is for a single screen */
1263 g_ScreenInfo
[g_iLastScreen
].fNoTrayIcon
= FALSE
;
1266 /* Indicate that we have processed this argument */
1271 * Look for the '-fp' argument
1273 if (IS_OPTION ("-fp"))
1276 g_cmdline
.fontPath
= argv
[++i
];
1277 return 0; /* Let DIX parse this again */
1281 * Look for the '-co' argument
1283 if (IS_OPTION ("-co"))
1286 g_cmdline
.rgbPath
= argv
[++i
];
1287 return 0; /* Let DIX parse this again */
1291 * Look for the '-query' argument
1293 if (IS_OPTION ("-query"))
1296 g_fXdmcpEnabled
= TRUE
;
1297 g_pszQueryHost
= argv
[++i
];
1298 return 0; /* Let DIX parse this again */
1302 * Look for the '-indirect' or '-broadcast' arguments
1304 if (IS_OPTION ("-indirect")
1305 || IS_OPTION ("-broadcast"))
1307 g_fXdmcpEnabled
= TRUE
;
1308 return 0; /* Let DIX parse this again */
1312 * Look for the '-config' argument
1314 if (IS_OPTION ("-config")
1315 || IS_OPTION ("-xf86config"))
1318 #ifdef XWIN_XF86CONFIG
1319 g_cmdline
.configFile
= argv
[++i
];
1321 winMessageBoxF ("The %s option is not supported in this "
1323 "Ignoring this option and continuing.\n",
1331 * Look for the '-keyboard' argument
1333 if (IS_OPTION ("-keyboard"))
1335 #ifdef XWIN_XF86CONFIG
1337 g_cmdline
.keyboard
= argv
[++i
];
1339 winMessageBoxF ("The -keyboard option is not supported in this "
1341 "Ignoring this option and continuing.\n",
1342 MB_ICONINFORMATION
);
1348 * Look for the '-logfile' argument
1350 if (IS_OPTION ("-logfile"))
1353 g_pszLogFile
= argv
[++i
];
1354 #ifdef RELOCATE_PROJECTROOT
1355 g_fLogFileChanged
= TRUE
;
1361 * Look for the '-logverbose' argument
1363 if (IS_OPTION ("-logverbose"))
1366 g_iLogVerbose
= atoi(argv
[++i
]);
1370 #ifdef XWIN_CLIPBOARD
1372 * Look for the '-nounicodeclipboard' argument
1374 if (IS_OPTION ("-nounicodeclipboard"))
1376 g_fUnicodeClipboard
= FALSE
;
1377 /* Indicate that we have processed the argument */
1384 * Look for the '-kb' argument
1386 if (IS_OPTION ("-kb"))
1388 g_cmdline
.noXkbExtension
= TRUE
;
1389 return 0; /* Let DIX parse this again */
1392 if (IS_OPTION ("-xkbrules"))
1395 g_cmdline
.xkbRules
= argv
[++i
];
1398 if (IS_OPTION ("-xkbmodel"))
1401 g_cmdline
.xkbModel
= argv
[++i
];
1404 if (IS_OPTION ("-xkblayout"))
1407 g_cmdline
.xkbLayout
= argv
[++i
];
1410 if (IS_OPTION ("-xkbvariant"))
1413 g_cmdline
.xkbVariant
= argv
[++i
];
1416 if (IS_OPTION ("-xkboptions"))
1419 g_cmdline
.xkbOptions
= argv
[++i
];
1424 if (IS_OPTION ("-keyhook"))
1426 g_fKeyboardHookLL
= TRUE
;
1430 if (IS_OPTION ("-nokeyhook"))
1432 g_fKeyboardHookLL
= FALSE
;
1436 if (IS_OPTION ("-swcursor"))
1438 g_fSoftwareCursor
= TRUE
;
1442 if (IS_OPTION ("-silent-dup-error"))
1444 g_fSilentDupError
= TRUE
;
1452 * winLogCommandLine - Write entire command line to the log file
1456 winLogCommandLine (int argc
, char *argv
[])
1462 #define CHARS_PER_LINE 60
1464 /* Bail if command line has already been logged */
1465 if (g_pszCommandLine
)
1468 /* Count how much memory is needed for concatenated command line */
1469 for (i
= 0, iCurrLen
= 0; i
< argc
; ++i
)
1472 /* Add a character for lines that overflow */
1473 if ((strlen (argv
[i
]) < CHARS_PER_LINE
1474 && iCurrLen
+ strlen (argv
[i
]) > CHARS_PER_LINE
)
1475 || strlen (argv
[i
]) > CHARS_PER_LINE
)
1481 /* Add space for item and trailing space */
1482 iSize
+= strlen (argv
[i
]) + 1;
1484 /* Update current line length */
1485 iCurrLen
+= strlen (argv
[i
]);
1488 /* Allocate memory for concatenated command line */
1489 g_pszCommandLine
= malloc (iSize
+ 1);
1490 if (!g_pszCommandLine
)
1491 FatalError ("winLogCommandLine - Could not allocate memory for "
1492 "command line string. Exiting.\n");
1494 /* Set first character to concatenated command line to null */
1495 g_pszCommandLine
[0] = '\0';
1497 /* Loop through all args */
1498 for (i
= 0, iCurrLen
= 0; i
< argc
; ++i
)
1500 /* Add a character for lines that overflow */
1501 if ((strlen (argv
[i
]) < CHARS_PER_LINE
1502 && iCurrLen
+ strlen (argv
[i
]) > CHARS_PER_LINE
)
1503 || strlen (argv
[i
]) > CHARS_PER_LINE
)
1507 /* Add line break if it fits */
1508 strncat (g_pszCommandLine
, "\n", iSize
- strlen (g_pszCommandLine
));
1511 strncat (g_pszCommandLine
, argv
[i
], iSize
- strlen (g_pszCommandLine
));
1512 strncat (g_pszCommandLine
, " ", iSize
- strlen (g_pszCommandLine
));
1514 /* Save new line length */
1515 iCurrLen
+= strlen (argv
[i
]);
1518 ErrorF ("XWin was started with the following command line:\n\n"
1519 "%s\n\n", g_pszCommandLine
);
1524 * winLogVersionInfo - Log Cygwin/X version information
1528 winLogVersionInfo (void)
1530 static Bool s_fBeenHere
= FALSE
;
1536 ErrorF ("Welcome to the XWin X Server\n");
1537 ErrorF ("Vendor: %s\n", VENDOR_STRING
);
1538 ErrorF ("Release: %s\n\n", VERSION_STRING
);
1539 ErrorF ("Contact: %s\n\n", VENDOR_CONTACT
);
1543 * getMonitorInfo - callback function used to return information from the enumeration of monitors attached
1546 wBOOL CALLBACK
getMonitorInfo(HMONITOR hMonitor
, HDC hdc
, LPRECT rect
, LPARAM _data
)
1548 struct GetMonitorInfoData
* data
= (struct GetMonitorInfoData
*)_data
;
1549 // only get data for monitor number specified in <data>
1551 if (data
->monitorNum
== data
->requestedMonitor
)
1553 data
->bMonitorSpecifiedExists
= TRUE
;
1554 data
->monitorOffsetX
= rect
->left
;
1555 data
->monitorOffsetY
= rect
->top
;
1556 data
->monitorHeight
= rect
->bottom
- rect
->top
;
1557 data
->monitorWidth
= rect
->right
- rect
->left
;