diff options
Diffstat (limited to 'xorg-server/os/utils.c')
-rw-r--r-- | xorg-server/os/utils.c | 132 |
1 files changed, 95 insertions, 37 deletions
diff --git a/xorg-server/os/utils.c b/xorg-server/os/utils.c index e8ecb7193..8fd034af7 100644 --- a/xorg-server/os/utils.c +++ b/xorg-server/os/utils.c @@ -203,6 +203,11 @@ int auditTrailLevel = 1; char *SeatId = NULL; +#ifdef _MSC_VER +static HANDLE s_hSmartScheduleTimer = NULL; +static HANDLE s_hSmartScheduleTimerQueue = NULL; +#endif + #if defined(SVR4) || defined(__linux__) || defined(CSRG_BASED) #define HAS_SAVED_IDS_AND_SETEUID #endif @@ -210,6 +215,9 @@ char *SeatId = NULL; OsSigHandlerPtr OsSignal(int sig, OsSigHandlerPtr handler) { +#ifdef X_NOT_POSIX + return signal(sig, handler); +#else struct sigaction act, oact; sigemptyset(&act.sa_mask); @@ -220,6 +228,7 @@ OsSignal(int sig, OsSigHandlerPtr handler) if (sigaction(sig, &act, &oact)) perror("sigaction"); return oact.sa_handler; +#endif } /* @@ -233,6 +242,10 @@ OsSignal(int sig, OsSigHandlerPtr handler) #define LOCK_PREFIX "/.X" #define LOCK_SUFFIX "-lock" +#ifdef _MSC_VER +#define LockFile szLockFile +#endif + static Bool StillLocking = FALSE; static char LockFile[PATH_MAX]; static Bool nolock = FALSE; @@ -246,6 +259,14 @@ static Bool nolock = FALSE; void LockServer(void) { +#if defined(WIN32) && !defined(__CYGWIN__) + char MutexName[100]; + sprintf(MutexName, "Global\\VcXsrv_Mutex_%d\n", getpid()); + if (!CreateMutex(NULL,TRUE,MutexName) || GetLastError()== ERROR_ALREADY_EXISTS) + { + FatalError("Server is already active for display %d\n", atoi(display)); + } +#else char tmp[PATH_MAX], pid_str[12]; int lfd, i, haslock, l_pid, t; char *tmppath = NULL; @@ -363,6 +384,7 @@ LockServer(void) if (!haslock) FatalError("Could not create server lock file: %s\n", LockFile); StillLocking = FALSE; +#endif } /* @@ -467,7 +489,10 @@ AdjustWaitForDelay (pointer waitTime, unsigned long newdelay) void UseMsg(void) { - ErrorF("use: X [:<display>] [option]\n"); + ErrorF("Usage...\nVcxsrv [:<display>] [option]\n\n"); + ErrorF(":display-number\n\tVcxsrv runs as the given display-number, which defaults to 0.\n"); + ErrorF("\tTo run multiple instances, use unique display-numbers.\n\n"); + ErrorF("-a # default pointer acceleration (factor)\n"); ErrorF("-ac disable access control restrictions\n"); ErrorF("-audit int set audit trail level\n"); @@ -475,12 +500,14 @@ void UseMsg(void) ErrorF("-br create root window with black background\n"); ErrorF("+bs enable any backing store support\n"); ErrorF("-bs disable any backing store support\n"); - ErrorF("-c turns off key-click\n"); - ErrorF("c # key-click volume (0-100)\n"); ErrorF("-cc int default color visual class\n"); ErrorF("-nocursor disable the cursor\n"); ErrorF("-core generate core dump on fatal error\n"); +#ifdef _MSC_VER + ErrorF("-dpi [auto|int] screen resolution set to native or this dpi\n"); +#else ErrorF("-dpi int screen resolution in dots per inch\n"); +#endif #ifdef DPMSExtension ErrorF("-dpms disables VESA DPMS monitor control\n"); #endif @@ -505,32 +532,25 @@ void UseMsg(void) ErrorF("-noreset don't reset after last client exists\n"); ErrorF("-background [none] create root window with no background\n"); ErrorF("-reset reset after last client exists\n"); - ErrorF("-p # screen-saver pattern duration (minutes)\n"); ErrorF("-pn accept failure to listen on all ports\n"); ErrorF("-nopn reject failure to listen on all ports\n"); ErrorF("-r turns off auto-repeat\n"); ErrorF("r turns on auto-repeat \n"); ErrorF("-render [default|mono|gray|color] set render color alloc policy\n"); - ErrorF("-retro start with classic stipple and cursor\n"); - ErrorF("-s # screen-saver timeout (minutes)\n"); + ErrorF("-retro start with classic stipple\n"); ErrorF("-seat string seat to run on\n"); ErrorF("-t # default pointer threshold (pixels/t)\n"); ErrorF("-terminate terminate at server reset\n"); ErrorF("-to # connection time out\n"); ErrorF("-tst disable testing extensions\n"); - ErrorF("ttyxx server started from init on /dev/ttyxx\n"); - ErrorF("v video blanking for screen-saver\n"); - ErrorF("-v screen-saver without video blanking\n"); ErrorF("-wm WhenMapped default backing-store\n"); ErrorF("-wr create root window with white background\n"); - ErrorF("-maxbigreqsize set maximal bigrequest size \n"); #ifdef PANORAMIX ErrorF("+xinerama Enable XINERAMA extension\n"); ErrorF("-xinerama Disable XINERAMA extension\n"); #endif ErrorF("-dumbSched Disable smart scheduling, enable old behavior\n"); ErrorF("-schedInterval int Set scheduler interval in msec\n"); - ErrorF("-sigstop Enable SIGSTOP based startup\n"); ErrorF("+extension name Enable extension\n"); ErrorF("-extension name Disable extension\n"); #ifdef XDMCP @@ -624,17 +644,6 @@ ProcessCommandLine(int argc, char *argv[]) enableBackingStore = TRUE; else if ( strcmp( argv[i], "-bs") == 0) disableBackingStore = TRUE; - else if ( strcmp( argv[i], "c") == 0) - { - if(++i < argc) - defaultKeyboardControl.click = atoi(argv[i]); - else - UseMsg(); - } - else if ( strcmp( argv[i], "-c") == 0) - { - defaultKeyboardControl.click = 0; - } else if ( strcmp( argv[i], "-cc") == 0) { if(++i < argc) @@ -659,7 +668,24 @@ ProcessCommandLine(int argc, char *argv[]) else if ( strcmp( argv[i], "-dpi") == 0) { if(++i < argc) +#ifdef _MSC_VER + { + if (strcmp(argv[i], "auto") == 0) + { + HDC hdc = GetDC(NULL); + if (hdc) + { + int dpiY = GetDeviceCaps(hdc, LOGPIXELSY); + monitorResolution = dpiY; + ReleaseDC(NULL, hdc); + } + } + else if (isdigit(*argv[i])) /* Naively prevent a crash if not numeric */ + monitorResolution = atoi(argv[i]); + } +#else monitorResolution = atoi(argv[i]); +#endif else UseMsg(); } @@ -834,10 +860,6 @@ ProcessCommandLine(int argc, char *argv[]) { noTestExtensions = TRUE; } - else if ( strcmp( argv[i], "v") == 0) - defaultScreenSaverBlanking = PreferBlanking; - else if ( strcmp( argv[i], "-v") == 0) - defaultScreenSaverBlanking = DontPreferBlanking; else if ( strcmp( argv[i], "-wm") == 0) defaultBackingStore = WhenMapped; else if ( strcmp( argv[i], "-wr") == 0) @@ -931,10 +953,6 @@ ProcessCommandLine(int argc, char *argv[]) else UseMsg (); } - else if ( strcmp( argv[i], "-sigstop") == 0) - { - RunFromSigStopParent = TRUE; - } else if ( strcmp( argv[i], "+extension") == 0) { if (++i < argc) @@ -1132,6 +1150,12 @@ XNFstrdup(const char *s) void SmartScheduleStopTimer (void) { +#ifdef _MSC_VER + if (SmartScheduleDisable) + return; + DeleteTimerQueueTimer(s_hSmartScheduleTimerQueue, s_hSmartScheduleTimer, NULL); + s_hSmartScheduleTimer=NULL; +#else struct itimerval timer; if (SmartScheduleDisable) @@ -1141,11 +1165,36 @@ SmartScheduleStopTimer (void) timer.it_value.tv_sec = 0; timer.it_value.tv_usec = 0; (void) setitimer (ITIMER_REAL, &timer, 0); +#endif +} + +#ifdef _MSC_VER +static VOID CALLBACK SmartScheduleTimer( PVOID lpParameter, BOOLEAN TimerOrWaitFired) +#else +static void SmartScheduleTimer (int sig) +#endif +{ + SmartScheduleTime += SmartScheduleInterval; } + void SmartScheduleStartTimer (void) { +#ifdef _MSC_VER + if (SmartScheduleDisable) + return; + + if (!CreateTimerQueueTimer( &s_hSmartScheduleTimer, s_hSmartScheduleTimerQueue, SmartScheduleTimer, NULL + , SmartScheduleInterval, SmartScheduleInterval, WT_EXECUTEONLYONCE|WT_EXECUTEINPERSISTENTTHREAD)) + { + DWORD Error=GetLastError(); + ErrorF("Error starting timer, smart scheduling disabled: 0x%x (%d)\n",Error,Error); + CloseHandle(s_hSmartScheduleTimer); + SmartScheduleDisable = TRUE; + return; + } +#else struct itimerval timer; if (SmartScheduleDisable) @@ -1155,17 +1204,23 @@ SmartScheduleStartTimer (void) timer.it_value.tv_sec = 0; timer.it_value.tv_usec = SmartScheduleInterval * 1000; setitimer (ITIMER_REAL, &timer, 0); -} - -static void -SmartScheduleTimer (int sig) -{ - SmartScheduleTime += SmartScheduleInterval; +#endif } void SmartScheduleInit (void) { +#ifdef _MSC_VER + if (SmartScheduleDisable) + return; + s_hSmartScheduleTimerQueue = CreateTimerQueue(); + if (!s_hSmartScheduleTimerQueue) + { + DWORD Error=GetLastError(); + ErrorF("Error creating timer, smart scheduling disabled: 0x%x (%d)\n",Error,Error); + SmartScheduleDisable = TRUE; + } +#else struct sigaction act; if (SmartScheduleDisable) @@ -1182,6 +1237,7 @@ SmartScheduleInit (void) perror ("sigaction for smart scheduler"); SmartScheduleDisable = TRUE; } +#endif } #ifdef SIG_BLOCK @@ -1536,6 +1592,7 @@ Fclose(pointer iop) */ /* Consider LD* variables insecure? */ +#ifndef _MSC_VER #ifndef REMOVE_ENV_LD #define REMOVE_ENV_LD 1 #endif @@ -1544,6 +1601,7 @@ Fclose(pointer iop) #ifndef REMOVE_LONG_ENV #define REMOVE_LONG_ENV 1 #endif +#endif /* * Disallow stdout or stderr as pipes? It's possible to block the X server @@ -1574,7 +1632,7 @@ Fclose(pointer iop) #endif #define MAX_ARG_LENGTH 128 -#define MAX_ENV_LENGTH 256 +#define MAX_ENV_LENGTH 2048 #define MAX_ENV_PATH_LENGTH 2048 /* Limit for *PATH and TERMCAP */ #if USE_ISPRINT |