diff options
Diffstat (limited to 'xorg-server/os/utils.c')
-rw-r--r-- | xorg-server/os/utils.c | 126 |
1 files changed, 92 insertions, 34 deletions
diff --git a/xorg-server/os/utils.c b/xorg-server/os/utils.c index 608ee6ab0..ff3b7e40a 100644 --- a/xorg-server/os/utils.c +++ b/xorg-server/os/utils.c @@ -73,6 +73,9 @@ __stdcall unsigned long GetTickCount(void); #include <sys/resource.h> # define SMART_SCHEDULE_POSSIBLE #endif +#ifdef _MSC_VER +# define SMART_SCHEDULE_POSSIBLE +#endif #include "misc.h" #include <X11/X.h> #define XSERV_t @@ -204,6 +207,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 @@ -238,6 +246,10 @@ OsSignal(int sig, OsSigHandlerPtr handler) #define LOCK_PREFIX "/.X" #define LOCK_SUFFIX "-lock" +#ifdef _MSC_VER +#define LockFile szLockFile +#endif + #if !defined(WIN32) || defined(__CYGWIN__) #define LOCK_SERVER #endif @@ -264,6 +276,14 @@ static Bool nolock = FALSE; void LockServer(void) { +#if defined(WIN32) && !defined(__CYGWIN__) + char MutexName[100]; + sprintf(MutexName, "Global\\VcXsrv_Mutex_%d\n", atoi(display)); + 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; @@ -381,6 +401,7 @@ LockServer(void) if (!haslock) FatalError("Could not create server lock file: %s\n", LockFile); StillLocking = FALSE; +#endif } /* @@ -513,7 +534,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"); @@ -521,12 +545,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 @@ -554,25 +580,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"); @@ -580,7 +600,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 @@ -672,15 +691,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]); @@ -702,7 +712,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(); } @@ -869,10 +896,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) @@ -956,9 +979,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)) @@ -1156,6 +1176,12 @@ void SmartScheduleStopTimer(void) { #ifdef SMART_SCHEDULE_POSSIBLE +#ifdef _MSC_VER + if (SmartScheduleDisable) + return; + DeleteTimerQueueTimer(s_hSmartScheduleTimerQueue, s_hSmartScheduleTimer, NULL); + s_hSmartScheduleTimer=NULL; +#else struct itimerval timer; if (SmartScheduleDisable) @@ -1166,12 +1192,37 @@ SmartScheduleStopTimer(void) timer.it_value.tv_usec = 0; (void) setitimer(ITIMER_REAL, &timer, 0); #endif +#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 SMART_SCHEDULE_POSSIBLE +#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) @@ -1182,18 +1233,24 @@ SmartScheduleStartTimer(void) timer.it_value.tv_usec = SmartScheduleInterval * 1000; setitimer(ITIMER_REAL, &timer, 0); #endif -} - -static void -SmartScheduleTimer(int sig) -{ - SmartScheduleTime += SmartScheduleInterval; +#endif } void SmartScheduleInit(void) { #ifdef SMART_SCHEDULE_POSSIBLE +#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) @@ -1210,6 +1267,7 @@ SmartScheduleInit(void) SmartScheduleDisable = TRUE; } #endif +#endif } #ifdef SIG_BLOCK @@ -1734,7 +1792,7 @@ System(const char *cmdline) #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 |