diff options
Diffstat (limited to 'xorg-server/os/utils.c')
-rw-r--r-- | xorg-server/os/utils.c | 129 |
1 files changed, 95 insertions, 34 deletions
diff --git a/xorg-server/os/utils.c b/xorg-server/os/utils.c index 998c3ed4a..e94179518 100644 --- a/xorg-server/os/utils.c +++ b/xorg-server/os/utils.c @@ -206,6 +206,11 @@ char *SeatId = NULL; sig_atomic_t inSignalContext = FALSE; +#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 @@ -213,6 +218,9 @@ sig_atomic_t inSignalContext = FALSE; OsSigHandlerPtr OsSignal(int sig, OsSigHandlerPtr handler) { +#ifdef X_NOT_POSIX + return signal(sig, handler); +#else struct sigaction act, oact; sigemptyset(&act.sa_mask); @@ -223,6 +231,7 @@ OsSignal(int sig, OsSigHandlerPtr handler) if (sigaction(sig, &act, &oact)) perror("sigaction"); return oact.sa_handler; +#endif } /* @@ -236,6 +245,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; @@ -249,6 +262,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; const char *tmppath = LOCK_DIR; @@ -366,6 +387,7 @@ LockServer(void) if (!haslock) FatalError("Could not create server lock file: %s\n", LockFile); StillLocking = FALSE; +#endif } /* @@ -470,7 +492,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"); @@ -478,12 +503,14 @@ 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 @@ -509,25 +536,19 @@ 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"); @@ -535,7 +556,6 @@ UseMsg(void) 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 @@ -627,15 +647,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) defaultColorVisualClass = atoi(argv[i]); @@ -657,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(); } @@ -820,10 +848,6 @@ ProcessCommandLine(int argc, char *argv[]) else if (strcmp(argv[i], "-tst") == 0) { 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) @@ -905,9 +929,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) { if (!EnableDisableExtension(argv[i], TRUE)) @@ -1104,6 +1125,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) @@ -1113,11 +1140,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) @@ -1127,17 +1179,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) @@ -1153,6 +1211,7 @@ SmartScheduleInit(void) perror("sigaction for smart scheduler"); SmartScheduleDisable = TRUE; } +#endif } #ifdef SIG_BLOCK @@ -1509,6 +1568,7 @@ Fclose(pointer iop) */ /* Consider LD* variables insecure? */ +#ifndef _MSC_VER #ifndef REMOVE_ENV_LD #define REMOVE_ENV_LD 1 #endif @@ -1517,6 +1577,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 @@ -1546,7 +1607,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 |