diff options
40 files changed, 642 insertions, 186 deletions
diff --git a/GL/windows/ChangeLog b/GL/windows/ChangeLog index 9732e8c86..66c78b829 100644 --- a/GL/windows/ChangeLog +++ b/GL/windows/ChangeLog @@ -1,3 +1,9 @@ +2004-11-15 Alexander Gottwald <ago at freedesktop dot org> + + * indirect.c: + Bufzilla #1802, http://freedesktop.org/bugzilla/show_bug.cgi?id=1802 + Added mingw (Win32) port + 2004-08-13 Alexander Gottwald <ago@freedesktop.org> * Imakefile: Added $(MESASRCDIR)/src/mesa/glapi to INCLUDES. diff --git a/GL/windows/indirect.c b/GL/windows/indirect.c index 11dc0c092..aa7211b87 100755 --- a/GL/windows/indirect.c +++ b/GL/windows/indirect.c @@ -44,8 +44,9 @@ #include "glwindows.h" #include <glcontextmodes.h> +#include <stdint.h> -#include "../../hw/xwin/winpriv.h" +#include <winpriv.h> #define GLWIN_DEBUG_HWND(hwnd) \ if (glWinDebugSettings.dumpHWND) { \ diff --git a/hw/xwin/ChangeLog b/hw/xwin/ChangeLog index a4abd46c4..904c1f031 100644 --- a/hw/xwin/ChangeLog +++ b/hw/xwin/ChangeLog @@ -1,3 +1,39 @@ +2004-11-15 Alexander Gottwald <ago at freedesktop dot org> + + * Imakefile: + * InitInput.c: (InitInput): + * InitOutput.c: (winClipboardShutdown), (ddxGiveUp), + (winCheckMount), (winGetBaseDir), (winFixupPaths), (OsVendorInit), + (winCheckDisplayNumber): + * win.h: + * winblock.c: (winBlockHandler): + * winclipboard.h: + * winclipboardthread.c: (winClipboardProc): + * winclipboardwndproc.c: (winClipboardWindowProc): + * winconfig.c: (winConfigKeyboard), (winConfigFiles): + * wincreatewnd.c: (winCreateBoundingWindowWindowed): + * windialogs.c: (winDisplayExitDialog), (winExitDlgProc), + (winAboutDlgProc): + * winengine.c: (winSetEngine): + * winerror.c: (OsVendorVErrorF), (winMessageBoxF), (scprintf): + * winglobals.c: (winInitializeGlobals): + * winkeybd.c: (winKeybdReleaseKeys): + * winmultiwindowicons.c: + * winmultiwindowwindow.c: (winCreateWindowsWindow): + * winmultiwindowwm.c: + * winprefs.c: (ReloadPrefs), (HandleCustomWM_COMMAND): + * winprocarg.c: (ddxProcessArgument): + * winscrinit.c: (winFinishScreenInitFB): + * winshadddnl.c: + * wintrayicon.c: (winHandleIconMessage): + * winwakeup.c: (winWakeupHandler): + * winwin32rootless.c: (winMWExtWMCreateFrame): + * winwindow.c: (winReshapeRootless): + * winwindow.h: + * winwndproc.c: (winWindowProc): + Bufzilla #1802, http://freedesktop.org/bugzilla/show_bug.cgi?id=1802 + Added mingw (Win32) port + 2004-11-06 Alexander Gottwald <ago at freedesktop dot org> * winwndproc.c, wintrayicon.c, winscrinit.c: diff --git a/hw/xwin/InitInput.c b/hw/xwin/InitInput.c index 6219fa2b9..e2277e45f 100644 --- a/hw/xwin/InitInput.c +++ b/hw/xwin/InitInput.c @@ -57,7 +57,9 @@ CARD32 g_c32LastInputEventTime = 0; * References to external symbols */ +#ifdef HAS_DEVWINDOWS extern int g_fdMessageQueue; +#endif extern Bool g_fXdmcpEnabled; #ifdef XWIN_CLIPBOARD extern winDispatchProcPtr winProcEstablishConnectionOrig; @@ -150,6 +152,7 @@ InitInput (int argc, char *argv[]) /* Initialize the mode key states */ winInitializeModeKeyStates (); +#ifdef HAS_DEVWINDOWS /* Only open the windows message queue device once */ if (g_fdMessageQueue == WIN_FD_INVALID) { @@ -165,6 +168,7 @@ InitInput (int argc, char *argv[]) /* Add the message queue as a device to wait for in WaitForSomething */ AddEnabledDevice (g_fdMessageQueue); } +#endif #if CYGDEBUG winDebug ("InitInput - returning\n"); diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c index dafd7e7fd..ad668720c 100644 --- a/hw/xwin/InitOutput.c +++ b/hw/xwin/InitOutput.c @@ -32,8 +32,15 @@ from The Open Group. #include "winmsg.h" #include "winconfig.h" #include "winprefs.h" +#ifdef XWIN_CLIPBOARD #include "X11/Xlocale.h" +#endif +#ifdef __CYGWIN__ #include <mntent.h> +#endif +#if defined(XKB) && defined(WIN32) +#include "XKBsrv.h" +#endif /* @@ -51,7 +58,9 @@ extern int g_iLogVerbose; Bool g_fLogInited; extern Bool g_fXdmcpEnabled; +#ifdef HAS_DEVWINDOWS extern int g_fdMessageQueue; +#endif extern const char * g_pszQueryHost; extern HINSTANCE g_hInstance; @@ -148,13 +157,7 @@ winClipboardShutdown (void) return; /* Wait for the clipboard thread to exit */ - if (g_ptClipboardProc) - { - pthread_join (g_ptClipboardProc, NULL); - g_ptClipboardProc = 0; - } - else - return; + pthread_join (g_ptClipboardProc, NULL); g_fClipboardLaunched = FALSE; g_fClipboardStarted = FALSE; @@ -206,6 +209,7 @@ ddxGiveUp (void) winDeinitMultiWindowWM (); #endif +#ifdef HAS_DEVWINDOWS /* Close our handle to our message queue */ if (g_fdMessageQueue != WIN_FD_INVALID) { @@ -215,6 +219,7 @@ ddxGiveUp (void) /* Set the file handle to invalid */ g_fdMessageQueue = WIN_FD_INVALID; } +#endif if (!g_fLogInited) { LogInit (g_pszLogFile, NULL); @@ -267,6 +272,7 @@ AbortDDX (void) ddxGiveUp (); } +#ifdef __CYGWIN__ /* hasmntopt is currently not implemented for cygwin */ const char *winCheckMntOpt(const struct mntent *mnt, const char *opt) { @@ -349,7 +355,278 @@ winCheckMount(void) if (!binary) winMsg(X_WARNING, "/tmp mounted int textmode\n"); } +#else +void +winCheckMount(void) +{ +} +#endif + +const char * +winGetBaseDir(void) +{ + static BOOL inited = FALSE; + static char buffer[MAX_PATH]; + if (!inited) + { + char *fendptr; + HMODULE module = GetModuleHandle(NULL); + DWORD size = GetModuleFileName(module, buffer, sizeof(buffer)); + if (sizeof(buffer) > 0) + buffer[sizeof(buffer)-1] = 0; + + fendptr = buffer + size; + while (fendptr > buffer) + { + if (*fendptr == '\\' || *fendptr == '/') + { + *fendptr = 0; + break; + } + fendptr--; + } + inited = TRUE; + } + return buffer; +} +static void +winFixupPaths (void) +{ + BOOL changed_fontpath = FALSE; + MessageType font_from = X_DEFAULT; +#ifdef RELOCATE_PROJECTROOT + const char *basedir = winGetBaseDir(); + size_t basedirlen = strlen(basedir); +#endif + +#ifdef READ_FONTDIRS + { + /* Open fontpath configuration file */ + FILE *fontdirs = fopen(ETCX11DIR "/font-dirs", "rt"); + if (fontdirs != NULL) + { + char buffer[256]; + int needs_sep = TRUE; + int comment_block = FALSE; + + /* get defautl fontpath */ + char *fontpath = xstrdup(defaultFontPath); + size_t size = strlen(fontpath); + + /* read all lines */ + while (!feof(fontdirs)) + { + size_t blen; + char *hashchar; + char *str; + int has_eol = FALSE; + + /* read one line */ + str = fgets(buffer, sizeof(buffer), fontdirs); + if (str == NULL) /* stop on error or eof */ + break; + + if (strchr(str, '\n') != NULL) + has_eol = TRUE; + + /* check if block is continued comment */ + if (comment_block) + { + /* ignore all input */ + *str = 0; + blen = 0; + if (has_eol) /* check if line ended in this block */ + comment_block = FALSE; + } + else + { + /* find comment character. ignore all trailing input */ + hashchar = strchr(str, '#'); + if (hashchar != NULL) + { + *hashchar = 0; + if (!has_eol) /* mark next block as continued comment */ + comment_block = TRUE; + } + } + + /* strip whitespaces from beginning */ + while (*str == ' ' || *str == '\t') + str++; + + /* get size, strip whitespaces from end */ + blen = strlen(str); + while (blen > 0 && (str[blen-1] == ' ' || + str[blen-1] == '\t' || str[blen-1] == '\n')) + { + str[--blen] = 0; + } + + /* still something left to add? */ + if (blen > 0) + { + size_t newsize = size + blen; + /* reserve one character more for ',' */ + if (needs_sep) + newsize++; + + /* allocate memory */ + if (fontpath == NULL) + fontpath = malloc(newsize+1); + else + fontpath = realloc(fontpath, newsize+1); + + /* add separator */ + if (needs_sep) + { + fontpath[size] = ','; + size++; + needs_sep = FALSE; + } + + /* mark next line as new entry */ + if (has_eol) + needs_sep = TRUE; + + /* add block */ + strncpy(fontpath + size, str, blen); + fontpath[newsize] = 0; + size = newsize; + } + } + + /* cleanup */ + fclose(fontdirs); + defaultFontPath = xstrdup(fontpath); + free(fontpath); + changed_fontpath = TRUE; + font_from = X_CONFIG; + } + } +#endif /* READ_FONTDIRS */ +#ifdef RELOCATE_PROJECTROOT + { + const char *libx11dir = PROJECTROOT "/lib/X11"; + size_t libx11dir_len = strlen(libx11dir); + char *newfp = NULL; + size_t newfp_len = 0; + const char *endptr, *ptr, *oldptr = defaultFontPath; + + endptr = oldptr + strlen(oldptr); + ptr = strchr(oldptr, ','); + if (ptr == NULL) + ptr = endptr; + while (ptr != NULL) + { + size_t oldfp_len = (ptr - oldptr); + size_t newsize = oldfp_len; + char *newpath = malloc(newsize + 1); + strncpy(newpath, oldptr, newsize); + newpath[newsize] = 0; + + + if (strncmp(libx11dir, newpath, libx11dir_len) == 0) + { + char *compose; + newsize = newsize - libx11dir_len + basedirlen; + compose = malloc(newsize + 1); + strcpy(compose, basedir); + strncat(compose, newpath + libx11dir_len, newsize - basedirlen); + compose[newsize] = 0; + free(newpath); + newpath = compose; + } + + oldfp_len = newfp_len; + if (oldfp_len > 0) + newfp_len ++; /* space for separator */ + newfp_len += newsize; + + if (newfp == NULL) + newfp = malloc(newfp_len + 1); + else + newfp = realloc(newfp, newfp_len + 1); + + if (oldfp_len > 0) + { + strcpy(newfp + oldfp_len, ","); + oldfp_len++; + } + strcpy(newfp + oldfp_len, newpath); + + free(newpath); + + if (*ptr == 0) + { + oldptr = ptr; + ptr = NULL; + } else + { + oldptr = ptr + 1; + ptr = strchr(oldptr, ','); + if (ptr == NULL) + ptr = endptr; + } + } + + defaultFontPath = xstrdup(newfp); + free(newfp); + changed_fontpath = TRUE; + } +#endif /* RELOCATE_PROJECTROOT */ + if (changed_fontpath) + winMsg (font_from, "FontPath set to \"%s\"\n", defaultFontPath); + +#ifdef RELOCATE_PROJECTROOT + if (1) { + const char *libx11dir = "/usr/X11R6/lib/X11"; + size_t libx11dir_len = strlen(libx11dir); + + if (strncmp(libx11dir, rgbPath, libx11dir_len) == 0) + { + size_t newsize = strlen(rgbPath) - libx11dir_len + basedirlen; + char *compose = malloc(newsize + 1); + strcpy(compose, basedir); + strcat(compose, rgbPath + libx11dir_len); + compose[newsize] = 0; + rgbPath = xstrdup (compose); + free (compose); + + winMsg (X_DEFAULT, "RgbPath set to \"%s\"\n", rgbPath); + } + } + + if (getenv("XKEYSYMDB") == NULL) + { + char buffer[MAX_PATH]; + snprintf(buffer, sizeof(buffer), "XKEYSYMDB=%s\\XKeysymDB", + basedir); + buffer[sizeof(buffer)-1] = 0; + putenv(buffer); + winDebug("%s\n", getenv("XKEYSYMDB")); + } + if (getenv("XLOCALEDIR") == NULL) + { + char buffer[MAX_PATH]; + snprintf(buffer, sizeof(buffer), "XLOCALEDIR=%s\\locale", + basedir); + buffer[sizeof(buffer)-1] = 0; + putenv(buffer); + winDebug("%s\n", getenv("XLOCALEDIR")); + } +#ifdef XKB + { + static char xkbbasedir[MAX_PATH]; + + snprintf(xkbbasedir, sizeof(xkbbasedir), "%s\\xkb", basedir); + if (sizeof(xkbbasedir) > 0) + xkbbasedir[sizeof(xkbbasedir)-1] = 0; + XkbBaseDirectory = xkbbasedir; + } +#endif /* XKB */ +#endif /* RELOCATE_PROJECTROOT */ +} void OsVendorInit (void) @@ -404,6 +681,10 @@ OsVendorInit (void) /* We have to flag this as an explicit screen, even though it isn't */ g_ScreenInfo[0].fExplicitScreen = TRUE; } + + winFixupPaths(); + + XSupportsLocale(); } @@ -760,7 +1041,7 @@ winCheckDisplayNumber () } /* Setup Cygwin/X specific part of name */ - sprintf (name, "%sCYGWINX_DISPLAY:%d", pszPrefix, nDisp); + snprintf (name, sizeof(name), "%sCYGWINX_DISPLAY:%d", pszPrefix, nDisp); /* Windows automatically releases the mutex when this process exits */ mutex = CreateMutex (NULL, FALSE, name); diff --git a/hw/xwin/win.h b/hw/xwin/win.h index 759d18657..06155508f 100644 --- a/hw/xwin/win.h +++ b/hw/xwin/win.h @@ -139,8 +139,22 @@ #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> +#ifndef HAS_SCPRINTF +extern int scprintf(const char *format, ...); +#else +#ifdef WIN32 +#define scprintf _scprintf +#endif +#endif + +#ifndef __CYGWIN__ +#define sleep(x) Sleep(1000 * (x)) +#endif + #include <errno.h> +#if defined(XWIN_MULTIWINDOWEXTWM) || defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW) #include <pthread.h> +#endif #ifdef HAS_MMAP #include <sys/mman.h> @@ -220,11 +234,10 @@ if (fDebugProcMsg) \ char *pszTemp; \ int iLength; \ \ - iLength = sprintf (NULL, str, ##__VA_ARGS__); \ - \ + iLength = scprintf (str, ##__VA_ARGS__); \ pszTemp = malloc (iLength + 1); \ - \ - sprintf (pszTemp, str, ##__VA_ARGS__); \ + snprintf (pszTemp, iLength + 1, str, ##__VA_ARGS__); \ + pszTemp[iLength] = 0; \ \ MessageBox (NULL, pszTemp, szFunctionName, MB_OK); \ \ @@ -626,7 +639,9 @@ typedef struct { extern winScreenInfo g_ScreenInfo[]; extern miPointerScreenFuncRec g_winPointerCursorFuncs; extern DWORD g_dwEvents; +#ifdef HAS_DEVWINDOWS extern int g_fdMessageQueue; +#endif extern int g_iScreenPrivateIndex; extern int g_iCmapPrivateIndex; extern int g_iGCPrivateIndex; diff --git a/hw/xwin/winblock.c b/hw/xwin/winblock.c index a7ca230c5..37da595a7 100644 --- a/hw/xwin/winblock.c +++ b/hw/xwin/winblock.c @@ -48,8 +48,15 @@ winBlockHandler (int nScreen, pointer pTimeout, pointer pReadMask) { +#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW) winScreenPriv((ScreenPtr)pBlockData); +#endif MSG msg; +#ifndef HAS_DEVWINDOWS + struct timeval **tvp = pTimeout; + (*tvp)->tv_sec = 0; + (*tvp)->tv_usec = 100; +#endif #if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW) /* Signal threaded modules to begin */ diff --git a/hw/xwin/winclipboard.h b/hw/xwin/winclipboard.h index 225f50418..559409a81 100644 --- a/hw/xwin/winclipboard.h +++ b/hw/xwin/winclipboard.h @@ -35,7 +35,12 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#ifdef __CYGWIN__ #include <sys/select.h> +#else +#include "Xwinsock.h" +#define HAS_WINSOCK +#endif #include <fcntl.h> #include <setjmp.h> #include <pthread.h> @@ -54,6 +59,10 @@ /* Fixups to prevent collisions between Windows and X headers */ #define ATOM DWORD +#ifndef __CYGWIN__ +#define sleep(x) Sleep (1000 * (x)) +#endif + /* Windows headers */ #ifndef XFree86Server #define XFree86Server @@ -65,7 +74,9 @@ /* Clipboard module constants */ #define WIN_CLIPBOARD_WINDOW_CLASS "xwinclip" #define WIN_CLIPBOARD_WINDOW_TITLE "xwinclip" -#define WIN_MSG_QUEUE_FNAME "/dev/windows" +#ifdef HAS_DEVWINDOWS +# define WIN_MSG_QUEUE_FNAME "/dev/windows" +#endif #define WIN_CONNECT_RETRIES 40 #define WIN_CONNECT_DELAY 4 #define WIN_JMP_OKAY 0 diff --git a/hw/xwin/winclipboardthread.c b/hw/xwin/winclipboardthread.c index 4778d2a3b..a1f73ed82 100644 --- a/hw/xwin/winclipboardthread.c +++ b/hw/xwin/winclipboardthread.c @@ -29,6 +29,9 @@ */ #include "winclipboard.h" +#ifdef __CYGWIN__ +#include <errno.h> +#endif #include "X11/Xauth.h" @@ -86,7 +89,11 @@ winClipboardProc (void *pvNotUsed) int iReturn; HWND hwnd = NULL; int iConnectionNumber = 0; +#ifdef HAS_DEVWINDOWS int fdMessageQueue = 0; +#else + struct timeval tvTimeout; +#endif fd_set fdsRead; int iMaxDescriptor; Display *pDisplay = NULL; @@ -94,6 +101,7 @@ winClipboardProc (void *pvNotUsed) int iRetries; Bool fUseUnicode; char szDisplay[512]; + int iSelectError; ErrorF ("winClipboardProc - Hello\n"); @@ -204,6 +212,7 @@ winClipboardProc (void *pvNotUsed) /* Get our connection number */ iConnectionNumber = ConnectionNumber (pDisplay); +#ifdef HAS_DEVWINDOWS /* Open a file descriptor for the windows message queue */ fdMessageQueue = open (WIN_MSG_QUEUE_FNAME, O_RDONLY); if (fdMessageQueue == -1) @@ -214,6 +223,9 @@ winClipboardProc (void *pvNotUsed) /* Find max of our file descriptors */ iMaxDescriptor = max (fdMessageQueue, iConnectionNumber) + 1; +#else + iMaxDescriptor = iConnectionNumber + 1; +#endif /* Select event types to watch */ if (XSelectInput (pDisplay, @@ -242,10 +254,6 @@ winClipboardProc (void *pvNotUsed) pthread_exit (NULL); } -#if 0 - ErrorF ("winClipboardProc - iWindow: %d\n", iWindow); -#endif - /* Save the window in the screen privates */ g_iClipboardWindow = iWindow; @@ -255,17 +263,6 @@ winClipboardProc (void *pvNotUsed) /* Save copy of HWND in screen privates */ g_hwndClipboard = hwnd; -#if 0 - /* Assert ownership of CLIPBOARD_MANAGER */ - iReturn = XSetSelectionOwner (pDisplay, atomClipboardManager, - iWindow, CurrentTime); - if (iReturn == BadAtom || iReturn == BadWindow) - { - ErrorF ("winClipboardProc - Could not set CLIPBOARD_MANAGER owner\n"); - pthread_exit (NULL); - } -#endif - /* Assert ownership of selections if Win32 clipboard is owned */ if (NULL != GetClipboardOwner ()) { @@ -316,17 +313,41 @@ winClipboardProc (void *pvNotUsed) * which descriptors are ready. */ FD_ZERO (&fdsRead); - FD_SET (fdMessageQueue, &fdsRead); FD_SET (iConnectionNumber, &fdsRead); +#ifdef HAS_DEVWINDOWS + FD_SET (fdMessageQueue, &fdsRead); +#else + tvTimeout.tv_sec = 0; + tvTimeout.tv_usec = 100; +#endif /* Wait for a Windows event or an X event */ iReturn = select (iMaxDescriptor, /* Highest fds number */ &fdsRead, /* Read mask */ NULL, /* No write mask */ NULL, /* No exception mask */ - NULL); /* No timeout */ - if (iReturn <= 0) +#ifdef HAS_DEVWINDOWS + NULL /* No timeout */ +#else + &tvTimeout /* Set timeout */ +#endif + ); + +#ifndef HAS_WINSOCK + iSelectError = errno; +#else + iSelectError = WSAGetLastError(); +#endif + + if (iReturn < 0) { +#ifndef HAS_WINSOCK + if (iSelectError == EINTR) +#else + if (iSelectError == WSAEINTR) +#endif + continue; + ErrorF ("winClipboardProc - Call to select () failed: %d. " "Bailing.\n", iReturn); break; @@ -335,11 +356,6 @@ winClipboardProc (void *pvNotUsed) /* Branch on which descriptor became active */ if (FD_ISSET (iConnectionNumber, &fdsRead)) { - /* X event ready */ -#if 0 - ErrorF ("winClipboardProc - X event ready\n"); -#endif - /* Process X events */ /* Exit when we see that server is shutting down */ iReturn = winClipboardFlushXEvents (hwnd, @@ -354,14 +370,13 @@ winClipboardProc (void *pvNotUsed) } } +#ifdef HAS_DEVWINDOWS /* Check for Windows event ready */ if (FD_ISSET (fdMessageQueue, &fdsRead)) - { - /* Windows event ready */ -#if 0 - ErrorF ("winClipboardProc - Windows event ready\n"); +#else + if (1) #endif - + { /* Process Windows messages */ if (!winClipboardFlushWindowsMessageQueue (hwnd)) { @@ -383,9 +398,12 @@ winClipboardProc (void *pvNotUsed) ErrorF ("winClipboardProc - XDestroyWindow succeeded.\n"); } + +#ifdef HAS_DEVWINDOWS /* Close our Win32 message handle */ if (fdMessageQueue) close (fdMessageQueue); +#endif #if 0 /* diff --git a/hw/xwin/winclipboardwndproc.c b/hw/xwin/winclipboardwndproc.c index cfc97a51b..249f64b59 100644 --- a/hw/xwin/winclipboardwndproc.c +++ b/hw/xwin/winclipboardwndproc.c @@ -334,6 +334,8 @@ winClipboardWindowProc (HWND hwnd, UINT message, * previous XSetSelectionOwner messages. */ XSync (pDisplay, FALSE); + + winDebug("winClipboardWindowProc - XSync done.\n"); /* Release PRIMARY selection if owned */ iReturn = XGetSelectionOwner (pDisplay, XA_PRIMARY); diff --git a/hw/xwin/winconfig.c b/hw/xwin/winconfig.c index b8c773268..40d8bd0a6 100644 --- a/hw/xwin/winconfig.c +++ b/hw/xwin/winconfig.c @@ -374,7 +374,7 @@ winConfigKeyboard (DeviceIntPtr pDevice) char lname[256]; DWORD namesize = sizeof(lname); - regpath = alloca(sizeof(regtempl) + KL_NAMELENGTH + 1); + regpath = malloc(sizeof(regtempl) + KL_NAMELENGTH + 1); strcpy(regpath, regtempl); strcat(regpath, layoutName); @@ -388,6 +388,7 @@ winConfigKeyboard (DeviceIntPtr pDevice) /* Close registry key */ if (regkey) RegCloseKey (regkey); + free(regpath); } } @@ -737,117 +738,19 @@ winConfigFiles () MessageType from; /* Fontpath */ - from = X_DEFAULT; - if (g_cmdline.fontPath) { - from = X_CMDLINE; defaultFontPath = g_cmdline.fontPath; + winMsg (X_CMDLINE, "FontPath set to \"%s\"\n", defaultFontPath); } - else - { - /* Open fontpath configuration file */ - FILE *fontdirs = fopen(ETCX11DIR "/font-dirs", "rt"); - if (fontdirs != NULL) - { - char buffer[256]; - int needs_sep = TRUE; - int comment_block = FALSE; - - /* get defautl fontpath */ - char *fontpath = xstrdup(defaultFontPath); - size_t size = strlen(fontpath); - - /* read all lines */ - while (!feof(fontdirs)) - { - size_t blen; - char *hashchar; - char *str; - int has_eol = FALSE; - - /* read one line */ - str = fgets(buffer, sizeof(buffer), fontdirs); - if (str == NULL) /* stop on error or eof */ - break; - - if (strchr(str, '\n') != NULL) - has_eol = TRUE; - - /* check if block is continued comment */ - if (comment_block) - { - /* ignore all input */ - *str = 0; - blen = 0; - if (has_eol) /* check if line ended in this block */ - comment_block = FALSE; - } - else - { - /* find comment character. ignore all trailing input */ - hashchar = strchr(str, '#'); - if (hashchar != NULL) - { - *hashchar = 0; - if (!has_eol) /* mark next block as continued comment */ - comment_block = TRUE; - } - } - - /* strip whitespaces from beginning */ - while (*str == ' ' || *str == '\t') - str++; - - /* get size, strip whitespaces from end */ - blen = strlen(str); - while (blen > 0 && (str[blen-1] == ' ' || - str[blen-1] == '\t' || str[blen-1] == '\n')) - { - str[--blen] = 0; - } - - /* still something left to add? */ - if (blen > 0) - { - size_t newsize = size + blen; - /* reserve one character more for ',' */ - if (needs_sep) - newsize++; - - /* allocate memory */ - if (fontpath == NULL) - fontpath = malloc(newsize+1); - else - fontpath = realloc(fontpath, newsize+1); - - /* add separator */ - if (needs_sep) - { - fontpath[size] = ','; - size++; - needs_sep = FALSE; - } - - /* mark next line as new entry */ - if (has_eol) - needs_sep = TRUE; - - /* add block */ - strncpy(fontpath + size, str, blen); - fontpath[newsize] = 0; - size = newsize; - } - } - /* cleanup */ - fclose(fontdirs); - from = X_CONFIG; - defaultFontPath = xstrdup(fontpath); - free(fontpath); - } + /* RGBPath */ + if (g_cmdline.rgbPath) + { + from = X_CMDLINE; + rgbPath = g_cmdline.rgbPath; + winMsg (X_CMDLINE, "RgbPath set to \"%s\"\n", rgbPath); } - winMsg (from, "FontPath set to \"%s\"\n", defaultFontPath); return TRUE; } diff --git a/hw/xwin/wincreatewnd.c b/hw/xwin/wincreatewnd.c index 4c74f89e2..310771809 100644 --- a/hw/xwin/wincreatewnd.c +++ b/hw/xwin/wincreatewnd.c @@ -419,7 +419,9 @@ winCreateBoundingWindowWindowed (ScreenPtr pScreen) #endif ) { +#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) pScreenPriv->fRootWindowShown = FALSE; +#endif ShowWindow (*phwnd, SW_HIDE); } else diff --git a/hw/xwin/windialogs.c b/hw/xwin/windialogs.c index af0e4d9b8..decbd8531 100755 --- a/hw/xwin/windialogs.c +++ b/hw/xwin/windialogs.c @@ -30,7 +30,9 @@ */ #include "win.h" +#ifdef __CYGWIN__ #include <sys/cygwin.h> +#endif #include <shellapi.h> #include "winprefs.h" @@ -44,7 +46,9 @@ extern HWND g_hDlgDepthChange; extern HWND g_hDlgExit; extern HWND g_hDlgAbout; extern WINPREFS pref; +#ifdef XWIN_CLIPBOARD extern Bool g_fClipboardStarted; +#endif extern Bool g_fSoftwareCursor; @@ -217,11 +221,15 @@ winDisplayExitDialog (winPrivScreenPtr pScreenPriv) for (i = 1; i < currentMaxClients; i++) if (clients[i] != NullClient) liveClients++; +#if defined(XWIN_MULTIWINDOW) /* Count down server internal clients */ if (pScreenPriv->pScreenInfo->fMultiWindow) liveClients -= 2; /* multiwindow window manager & XMsgProc */ +#endif +#if defined(XWIN_CLIPBOARD) if (g_fClipboardStarted) liveClients--; /* clipboard manager */ +#endif /* A user reported that this sometimes drops below zero. just eye-candy. */ if (liveClients < 0) @@ -314,7 +322,7 @@ winExitDlgProc (HWND hDialog, UINT message, MAKEINTRESOURCE(IDI_XWIN))); /* Format the connected clients string */ - iReturn = sprintf (NULL, CONNECTED_CLIENTS_FORMAT, + iReturn = scprintf (CONNECTED_CLIENTS_FORMAT, s_pScreenPriv->iConnectedClients); if (iReturn <= 0) return TRUE; @@ -323,6 +331,7 @@ winExitDlgProc (HWND hDialog, UINT message, return TRUE; snprintf (pszConnectedClients, iReturn + 1, CONNECTED_CLIENTS_FORMAT, s_pScreenPriv->iConnectedClients); + pszConnectedClients[iReturn] = 0; /* Set the number of connected clients */ SetWindowText (GetDlgItem (hDialog, IDC_CLIENTS_CONNECTED), @@ -669,13 +678,18 @@ winAboutDlgProc (HWND hwndDialog, UINT message, case ID_ABOUT_CHANGELOG: { + int iReturn; +#ifdef __CYGWIN__ const char * pszCygPath = "/usr/X11R6/share/doc/" "xorg-x11-xwin/changelog.html"; char pszWinPath[MAX_PATH + 1]; - int iReturn; /* Convert the POSIX path to a Win32 path */ cygwin_conv_to_win32_path (pszCygPath, pszWinPath); +#else + const char * pszWinPath = "http://x.cygwin.com/" + "devel/server/changelog.html"; +#endif iReturn = (int) ShellExecute (NULL, "open", diff --git a/hw/xwin/winengine.c b/hw/xwin/winengine.c index c7eb1285b..87a1dd2e1 100644 --- a/hw/xwin/winengine.c +++ b/hw/xwin/winengine.c @@ -204,6 +204,19 @@ winSetEngine (ScreenPtr pScreen) winSetEngineFunctionsShadowGDI (pScreen); return TRUE; } +#ifdef WIN_PSEUDOCOLOR8BITPLANE + /* Edited by Sebastian Haby + ShadowGDI is the only engine that supports PseudoColor "emulation" */ + if (pScreenInfo->fEmulatePseudo) + { + winErrorFVerb (2, "winSetEngine - EMULATEPSEUDO => ShadowGDI\n"); + pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI; + + /* Set engine function pointers */ + winSetEngineFunctionsShadowGDI (pScreen); + return TRUE; + } +#endif /* If the user's choice is supported, we'll use that */ if (g_dwEnginesSupported & pScreenInfo->dwEnginePreferred) diff --git a/hw/xwin/winerror.c b/hw/xwin/winerror.c index d5836b999..53730c7ed 100644 --- a/hw/xwin/winerror.c +++ b/hw/xwin/winerror.c @@ -43,16 +43,22 @@ OsVendorVErrorF (const char *pszFormat, va_list va_args); void OsVendorVErrorF (const char *pszFormat, va_list va_args) { +#if defined(XWIN_CLIPBOARD) || defined (XWIN_MULTIWINDOW) + /* make sure the clipboard and multiwindow threads do not interfere the + * main thread */ static pthread_mutex_t s_pmPrinting = PTHREAD_MUTEX_INITIALIZER; /* Lock the printing mutex */ pthread_mutex_lock (&s_pmPrinting); +#endif /* Print the error message to a log file, could be stderr */ LogVWrite (0, pszFormat, va_args); +#if defined(XWIN_CLIPBOARD) || defined (XWIN_MULTIWINDOW) /* Unlock the printing mutex */ pthread_mutex_unlock (&s_pmPrinting); +#endif } #endif @@ -94,17 +100,18 @@ winMessageBoxF (const char *pszError, UINT uType, ...) /* Get length of formatted error string */ va_start (args, uType); - i = sprintf (NULL, pszError, args); + i = scprintf (pszError, args); va_end (args); /* Allocate memory for formatted error string */ - pszErrorF = malloc (i); + pszErrorF = malloc (i + 1); if (!pszErrorF) goto winMessageBoxF_Cleanup; /* Create the formatted error string */ va_start (args, uType); - sprintf (pszErrorF, pszError, args); + snprintf (pszErrorF, i + 1, pszError, args); + pszErrorF[i] = 0; va_end (args); #define MESSAGEBOXF \ @@ -116,21 +123,22 @@ winMessageBoxF (const char *pszError, UINT uType, ...) "%s\n" /* Get length of message box string */ - i = sprintf (NULL, MESSAGEBOXF, + i = scprintf (MESSAGEBOXF, pszErrorF, VENDOR_STRING, VERSION_STRING, VENDOR_CONTACT, g_pszCommandLine); /* Allocate memory for message box string */ - pszMsgBox = malloc (i); + pszMsgBox = malloc (i + 1); if (!pszMsgBox) goto winMessageBoxF_Cleanup; /* Format the message box string */ - sprintf (pszMsgBox, MESSAGEBOXF, + snprintf (pszMsgBox, i + 1, MESSAGEBOXF, pszErrorF, VENDOR_STRING, VERSION_STRING, VENDOR_CONTACT, g_pszCommandLine); + pszMsgBox[i] = 0; /* Display the message box string */ MessageBox (NULL, @@ -145,3 +153,15 @@ winMessageBoxF (const char *pszError, UINT uType, ...) free (pszMsgBox); #undef MESSAGEBOXF } + +#ifndef HAS_SCPRINTF +extern int scprintf(const char *format, ...) +{ + int ret; + va_list va; + va_start(va, format); + ret = vsnprintf(NULL, 0, format, va); + va_end(va); + return ret; +} +#endif diff --git a/hw/xwin/winglobals.c b/hw/xwin/winglobals.c index f38df68c5..0dc1af81e 100644 --- a/hw/xwin/winglobals.c +++ b/hw/xwin/winglobals.c @@ -38,7 +38,9 @@ int g_iNumScreens = 0; winScreenInfo g_ScreenInfo[MAXSCREENS]; int g_iLastScreen = -1; +#ifdef HAS_DEVWINDOWS int g_fdMessageQueue = WIN_FD_INVALID; +#endif int g_iScreenPrivateIndex = -1; int g_iCmapPrivateIndex = -1; int g_iGCPrivateIndex = -1; @@ -55,7 +57,11 @@ const char * g_pszQueryHost = NULL; Bool g_fXdmcpEnabled = FALSE; HICON g_hIconX = NULL; HICON g_hSmallIconX = NULL; +#ifndef RELOCATE_PROJECTROOT char * g_pszLogFile = "/tmp/XWin.log"; +#else +char * g_pszLogFile = "XWin.log"; +#endif int g_iLogVerbose = 2; Bool g_fLogInited = FALSE; char * g_pszCommandLine = NULL; @@ -99,7 +105,7 @@ Bool g_fUnicodeClipboard = TRUE; Bool g_fClipboard = FALSE; Bool g_fClipboardLaunched = FALSE; Bool g_fClipboardStarted = FALSE; -pthread_t g_ptClipboardProc = 0; +pthread_t g_ptClipboardProc; HWND g_hwndClipboard = NULL; void *g_pClipboardDisplay = NULL; Window g_iClipboardWindow = None; @@ -124,6 +130,5 @@ winInitializeGlobals (void) g_pClipboardDisplay = NULL; g_atomLastOwnedSelection = None; g_hwndClipboard = NULL; - g_ptClipboardProc = 0; #endif } diff --git a/hw/xwin/winkeybd.c b/hw/xwin/winkeybd.c index 8fd9c49a6..c2d2f38c4 100644 --- a/hw/xwin/winkeybd.c +++ b/hw/xwin/winkeybd.c @@ -541,9 +541,11 @@ winKeybdReleaseKeys () { int i; +#ifdef HAS_DEVWINDOWS /* Verify that the mi input system has been initialized */ if (g_fdMessageQueue == WIN_FD_INVALID) return; +#endif /* Loop through all keys */ for (i = 0; i < NUM_KEYCODES; ++i) diff --git a/hw/xwin/winmultiwindowicons.c b/hw/xwin/winmultiwindowicons.c index 34151a46c..e57755f35 100755 --- a/hw/xwin/winmultiwindowicons.c +++ b/hw/xwin/winmultiwindowicons.c @@ -359,6 +359,7 @@ winXIconToHICON (WindowPtr pWin, int iconSize) * Change the Windows window icon */ +#ifdef XWIN_MULTIWINDOW void winUpdateIcon (Window id) { @@ -471,3 +472,4 @@ void winDestroyIcon(HICON hIcon) !winIconIsOverride((unsigned long)hIcon)) DestroyIcon (hIcon); } +#endif diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c index 7c369a4a4..f1c6e417a 100644 --- a/hw/xwin/winmultiwindowwindow.c +++ b/hw/xwin/winmultiwindowwindow.c @@ -524,7 +524,8 @@ winCreateWindowsWindow (WindowPtr pWin) } /* Add incrementing window ID to make unique class name */ - sprintf (pszWindowID, "-%x", s_iWindowID++); + snprintf (pszWindowID, sizeof(pszWindowID), "-%x", s_iWindowID++); + pszWindowID[sizeof(pszWindowID)-1] = 0; strcat (pszClass, pszWindowID); #if CYGMULTIWINDOW_DEBUG diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c index 266448dc7..608cf361c 100644 --- a/hw/xwin/winmultiwindowwm.c +++ b/hw/xwin/winmultiwindowwm.c @@ -68,7 +68,9 @@ extern void winDebug(const char *format, ...); #define WIN_CONNECT_RETRIES 5 #define WIN_CONNECT_DELAY 5 -#define WIN_MSG_QUEUE_FNAME "/dev/windows" +#ifdef HAS_DEVWINDOWS +# define WIN_MSG_QUEUE_FNAME "/dev/windows" +#endif #define WIN_JMP_OKAY 0 #define WIN_JMP_ERROR_IO 2 diff --git a/hw/xwin/winprefs.c b/hw/xwin/winprefs.c index ea36dd9b8..e59de037f 100644 --- a/hw/xwin/winprefs.c +++ b/hw/xwin/winprefs.c @@ -31,7 +31,9 @@ #include <stdio.h> #include <stdlib.h> +#ifdef __CYGWIN__ #include <sys/resource.h> +#endif #include "win.h" /* Fixups to prevent collisions between Windows and X headers */ @@ -281,7 +283,9 @@ ReloadPrefs (void) g_hIconX = NULL; g_hSmallIconX = NULL; +#ifdef XWIN_MULTIWINDOW winInitGlobalIcons(); +#endif #ifdef XWIN_MULTIWINDOW /* Rebuild the icons and menus */ @@ -348,6 +352,7 @@ HandleCustomWM_COMMAND (unsigned long hwndIn, /* Match! */ switch(m->menuItem[j].cmd) { +#ifdef __CYGWIN__ case CMD_EXEC: if (fork()==0) { @@ -372,7 +377,7 @@ HandleCustomWM_COMMAND (unsigned long hwndIn, else return TRUE; break; - +#endif case CMD_ALWAYSONTOP: if (!hwnd) return FALSE; diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c index 46d665013..7a1caf9e9 100755 --- a/hw/xwin/winprocarg.c +++ b/hw/xwin/winprocarg.c @@ -403,16 +403,20 @@ ddxProcessArgument (int argc, char *argv[], int i) /* Parameter is for all screens */ for (j = 0; j < MAXSCREENS; j++) { +#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) if (!g_ScreenInfo[j].fMultiMonitorOverride) g_ScreenInfo[j].fMultipleMonitors = FALSE; +#endif g_ScreenInfo[j].fFullScreen = TRUE; } } else { /* Parameter is for a single screen */ +#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride) g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE; +#endif g_ScreenInfo[g_iLastScreen].fFullScreen = TRUE; } @@ -459,16 +463,20 @@ ddxProcessArgument (int argc, char *argv[], int i) /* Parameter is for all screens */ for (j = 0; j < MAXSCREENS; j++) { +#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) if (!g_ScreenInfo[j].fMultiMonitorOverride) g_ScreenInfo[j].fMultipleMonitors = FALSE; +#endif g_ScreenInfo[j].fDecoration = FALSE; } } else { /* Parameter is for a single screen */ +#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride) g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE; +#endif g_ScreenInfo[g_iLastScreen].fDecoration = FALSE; } @@ -548,16 +556,20 @@ ddxProcessArgument (int argc, char *argv[], int i) /* Parameter is for all screens */ for (j = 0; j < MAXSCREENS; j++) { +#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) if (!g_ScreenInfo[j].fMultiMonitorOverride) g_ScreenInfo[j].fMultipleMonitors = FALSE; +#endif g_ScreenInfo[j].fRootless = TRUE; } } else { /* Parameter is for a single screen */ +#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride) g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE; +#endif g_ScreenInfo[g_iLastScreen].fRootless = TRUE; } @@ -579,16 +591,20 @@ ddxProcessArgument (int argc, char *argv[], int i) /* Parameter is for all screens */ for (j = 0; j < MAXSCREENS; j++) { +#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) if (!g_ScreenInfo[j].fMultiMonitorOverride) g_ScreenInfo[j].fMultipleMonitors = TRUE; +#endif g_ScreenInfo[j].fMultiWindow = TRUE; } } else { /* Parameter is for a single screen */ +#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride) g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE; +#endif g_ScreenInfo[g_iLastScreen].fMultiWindow = TRUE; } @@ -611,14 +627,18 @@ ddxProcessArgument (int argc, char *argv[], int i) /* Parameter is for all screens */ for (j = 0; j < MAXSCREENS; j++) { +#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) g_ScreenInfo[j].fMultiMonitorOverride = TRUE; +#endif g_ScreenInfo[j].fMultipleMonitors = TRUE; } } else { /* Parameter is for a single screen */ +#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride = TRUE; +#endif g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE; } @@ -640,14 +660,18 @@ ddxProcessArgument (int argc, char *argv[], int i) /* Parameter is for all screens */ for (j = 0; j < MAXSCREENS; j++) { +#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) g_ScreenInfo[j].fMultiMonitorOverride = TRUE; +#endif g_ScreenInfo[j].fMultipleMonitors = FALSE; } } else { /* Parameter is for a single screen */ +#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride = TRUE; +#endif g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE; } diff --git a/hw/xwin/winscrinit.c b/hw/xwin/winscrinit.c index 07332dc51..50c329419 100644 --- a/hw/xwin/winscrinit.c +++ b/hw/xwin/winscrinit.c @@ -257,7 +257,9 @@ winFinishScreenInitFB (int index, winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; VisualPtr pVisual = NULL; char *pbits = NULL; +#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW) int iReturn; +#endif /* Create framebuffer */ if (!(*pScreenPriv->pwinAllocateFB) (pScreen)) diff --git a/hw/xwin/winshadddnl.c b/hw/xwin/winshadddnl.c index 2ec28c957..243579a84 100644 --- a/hw/xwin/winshadddnl.c +++ b/hw/xwin/winshadddnl.c @@ -523,6 +523,7 @@ winAllocateFBShadowDDNL (ScreenPtr pScreen) } +#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) /* * Create a DirectDraw surface for the new multi-window window */ @@ -568,6 +569,7 @@ winFinishCreateWindowsWindowDDNL (WindowPtr pWin) } return TRUE; } +#endif /* diff --git a/hw/xwin/wintrayicon.c b/hw/xwin/wintrayicon.c index 2b8bc6c61..24cf9f90a 100755 --- a/hw/xwin/wintrayicon.c +++ b/hw/xwin/wintrayicon.c @@ -111,7 +111,9 @@ winHandleIconMessage (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, winPrivScreenPtr pScreenPriv) { +#ifdef XWIN_MULTIWINDOWEXTWM winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; +#endif switch (lParam) { diff --git a/hw/xwin/winwakeup.c b/hw/xwin/winwakeup.c index 4553a4636..0411d7c1a 100644 --- a/hw/xwin/winwakeup.c +++ b/hw/xwin/winwakeup.c @@ -51,7 +51,6 @@ winWakeupHandler (int nScreen, unsigned long ulResult, pointer pReadmask) { - winScreenPriv((ScreenPtr)pWakeupData); MSG msg; /* Process all messages on our queue */ diff --git a/hw/xwin/winwin32rootless.c b/hw/xwin/winwin32rootless.c index 04e940c02..ce0c2f948 100755 --- a/hw/xwin/winwin32rootless.c +++ b/hw/xwin/winwin32rootless.c @@ -276,7 +276,8 @@ winMWExtWMCreateFrame (RootlessWindowPtr pFrame, ScreenPtr pScreen, } /* Add incrementing window ID to make unique class name */ - sprintf (pszWindowID, "-%x", s_iWindowID++); + snprintf (pszWindowID, sizeof(pszWindowID), "-%x", s_iWindowID++); + pszWindowID[sizeof(pszWindowID)-1] = 0; strcat (pszClass, pszWindowID); #if CYGMULTIWINDOW_DEBUG diff --git a/hw/xwin/winwindow.c b/hw/xwin/winwindow.c index 86dd71178..e8067cb46 100644 --- a/hw/xwin/winwindow.c +++ b/hw/xwin/winwindow.c @@ -470,7 +470,7 @@ void winReshapeRootless (WindowPtr pWin) { int nRects; - ScreenPtr pScreen = pWin->drawable.pScreen; + /* ScreenPtr pScreen = pWin->drawable.pScreen;*/ RegionRec rrNewShape; BoxPtr pShape, pRects, pEnd; HRGN hRgn, hRgnRect; diff --git a/hw/xwin/winwindow.h b/hw/xwin/winwindow.h index cea662a86..a94c3a754 100644 --- a/hw/xwin/winwindow.h +++ b/hw/xwin/winwindow.h @@ -46,7 +46,9 @@ #define WINDOW_CLASS_X "cygwin/x X rl" #define WINDOW_TITLE_X "Cygwin/X X" #define WIN_WINDOW_PROP "cyg_window_prop_rl" -#define WIN_MSG_QUEUE_FNAME "/dev/windows" +#ifdef HAS_DEVWINDOWS +# define WIN_MSG_QUEUE_FNAME "/dev/windows" +#endif #define WIN_WID_PROP "cyg_wid_prop_rl" #define WIN_NEEDMANAGE_PROP "cyg_override_redirect_prop_rl" #ifndef CYGMULTIWINDOW_DEBUG diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c index 2cfb78eaa..67fc8d356 100644 --- a/hw/xwin/winwndproc.c +++ b/hw/xwin/winwndproc.c @@ -1148,8 +1148,10 @@ winWindowProc (HWND hwnd, UINT message, ShowCursor (TRUE); } +#ifdef XWIN_CLIPBOARD /* Make sure the clipboard chain is ok. */ winFixClipboardChain (); +#endif /* Call engine specific screen activation/deactivation function */ (*s_pScreenPriv->pwinActivateApp) (s_pScreen); diff --git a/os/WaitFor.c b/os/WaitFor.c index 4c4628552..20a8b6c38 100644 --- a/os/WaitFor.c +++ b/os/WaitFor.c @@ -222,7 +222,11 @@ WaitForSomething(int *pClientsReady) { i = Select (MaxClients, &LastSelectMask, NULL, NULL, wt); } +#ifndef WIN32 selecterr = errno; +#else + selecterr = WSAGetLastError(); +#endif WakeupHandler(i, (pointer)&LastSelectMask); #ifdef XTESTEXT1 if (playback_on) { @@ -244,18 +248,30 @@ WaitForSomething(int *pClientsReady) return 0; if (i < 0) { +#ifndef WIN32 if (selecterr == EBADF) /* Some client disconnected */ +#else + if (selecterr == WSAENOTSOCK) /* Some client disconnected */ +#endif { CheckConnections (); if (! XFD_ANYSET (&AllClients)) return 0; } +#ifndef WIN32 else if (selecterr == EINVAL) +#else + else if (selecterr == WSAEINVAL) +#endif { FatalError("WaitForSomething(): select: errno=%d\n", selecterr); - } + } +#ifndef WIN32 else if (selecterr != EINTR) +#else + else if (selecterr != WSAEINTR) +#endif { ErrorF("WaitForSomething(): select: errno=%d\n", selecterr); diff --git a/os/access.c b/os/access.c index 421ed771f..d687e3515 100644 --- a/os/access.c +++ b/os/access.c @@ -1,5 +1,5 @@ /* $Xorg: access.c,v 1.5 2001/02/09 02:05:23 xorgcvs Exp $ */ -/* $XdotOrg: xc/programs/Xserver/os/access.c,v 1.5 2004/07/17 01:13:31 alanc Exp $ */ +/* $XdotOrg: xc/programs/Xserver/os/access.c,v 1.6 2004/10/17 10:46:14 herrb Exp $ */ /*********************************************************** Copyright 1987, 1998 The Open Group @@ -531,7 +531,14 @@ DefineSelf (int fd) int family; register HOST *host; +#ifndef WIN32 struct utsname name; +#else + struct { + char nodename[512]; + } name; +#endif + register struct hostent *hp; union { @@ -555,8 +562,12 @@ DefineSelf (int fd) * see), whereas gethostname() kindly truncates it for me. */ #ifndef QNX4 +#ifndef WIN32 uname(&name); #else + gethostname(name.nodename, sizeof(name.nodename)); +#endif +#else /* QNX4's uname returns node number in name.nodename, not the hostname have to overwrite it */ char hname[1024]; @@ -1849,6 +1860,10 @@ ConvertAddr ( return FamilyLocal; #if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN) case AF_INET: +#ifdef WIN32 + if (16777343 == *(long*)&((struct sockaddr_in *) saddr)->sin_addr) + return FamilyLocal; +#endif *len = sizeof (struct in_addr); *addr = (pointer) &(((struct sockaddr_in *) saddr)->sin_addr); return FamilyInternet; diff --git a/os/connection.c b/os/connection.c index 137ff050d..9948ce80c 100644 --- a/os/connection.c +++ b/os/connection.c @@ -202,6 +202,10 @@ int *ConnectionTranslation = NULL; * This is clearly boggus and another form of storage which doesn't use the fd * as a direct index should really be implemented for NT. */ +#undef MAXSOCKS +#define MAXSOCKS 500 +#undef MAXSELECT +#define MAXSELECT 500 #define MAXFD 500 #endif @@ -94,6 +94,7 @@ CallbackListPtr FlushCallback; * systems are broken and return EWOULDBLOCK when they should return EAGAIN */ #ifndef __UNIXOS2__ +#ifndef WIN32 #if defined(EAGAIN) && defined(EWOULDBLOCK) #define ETEST(err) (err == EAGAIN || err == EWOULDBLOCK) #else @@ -103,6 +104,9 @@ CallbackListPtr FlushCallback; #define ETEST(err) (err == EWOULDBLOCK) #endif #endif +#else /* WIN32 The socket errorcodes differ from the normal errors*/ +#define ETEST(err) (err == EAGAIN || err == WSAEWOULDBLOCK) +#endif #else /* __UNIXOS2__ Writing to full pipes may return ENOSPC */ #define ETEST(err) (err == EAGAIN || err == EWOULDBLOCK || err == ENOSPC) #endif @@ -89,6 +89,11 @@ OR PERFORMANCE OF THIS SOFTWARE. #include "site.h" #include "opaque.h" +#ifdef WIN32 +#include <process.h> +#define getpid(x) _getpid(x) +#endif + #ifdef DDXOSVERRORF void (*OsVendorVErrorFProc)(const char *, va_list args) = NULL; @@ -191,7 +196,9 @@ LogInit(const char *fname, const char *backup) if (saveBuffer && bufferSize > 0) { fwrite(saveBuffer, bufferPos, 1, logFile); fflush(logFile); +#ifndef WIN32 fsync(fileno(logFile)); +#endif } } @@ -263,8 +270,10 @@ LogVWrite(int verb, const char *f, va_list args) fwrite(tmpBuffer, len, 1, logFile); if (logFlush) { fflush(logFile); +#ifndef WIN32 if (logSync) fsync(fileno(logFile)); +#endif } } else if (needBuffer) { /* diff --git a/os/osdep.h b/os/osdep.h index 2b9eb5674..4ab988057 100644 --- a/os/osdep.h +++ b/os/osdep.h @@ -260,6 +260,9 @@ extern OsCommPtr AvailableInput; extern WorkQueuePtr workQueue; /* added by raphael */ +#ifdef WIN32 +typedef long int fd_mask; +#endif #define ffs mffs extern int mffs(fd_mask); diff --git a/os/utils.c b/os/utils.c index 454f90145..69729c61d 100644 --- a/os/utils.c +++ b/os/utils.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/os/utils.c,v 1.8 2004/09/24 02:11:14 gisburn Exp $ */ +/* $XdotOrg: xc/programs/Xserver/os/utils.c,v 1.9 2004/09/29 04:17:44 gisburn Exp $ */ /* $Xorg: utils.c,v 1.5 2001/02/09 02:05:24 xorgcvs Exp $ */ /* @@ -81,7 +81,9 @@ OR PERFORMANCE OF THIS SOFTWARE. #undef _POSIX_SOURCE #endif #endif +#ifndef WIN32 #include <sys/wait.h> +#endif #if !defined(SYSV) && !defined(WIN32) && !defined(Lynx) && !defined(QNX4) #include <sys/resource.h> #endif @@ -1974,7 +1976,11 @@ Fclose(pointer iop) /* Check args and env only if running setuid (euid == 0 && euid != uid) ? */ #ifndef CHECK_EUID +#ifndef WIN32 #define CHECK_EUID 1 +#else +#define CHECK_EUID 0 +#endif #endif /* diff --git a/os/xdmcp.c b/os/xdmcp.c index d0f73513a..6cf792937 100644 --- a/os/xdmcp.c +++ b/os/xdmcp.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/os/xdmcp.c,v 1.2 2004/04/23 19:54:28 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/os/xdmcp.c,v 1.3 2004/07/20 15:15:13 ago Exp $ */ /* $Xorg: xdmcp.c,v 1.4 2001/01/31 13:37:19 pookie Exp $ */ /* * Copyright 1989 Network Computing Devices, Inc., Mountain View, California. @@ -17,17 +17,7 @@ /* $XFree86: xc/programs/Xserver/os/xdmcp.c,v 3.31 2003/12/30 21:24:32 herrb Exp $ */ #ifdef WIN32 -/* avoid conflicting definitions */ -#define BOOL wBOOL -#define ATOM wATOM -#define FreeResource wFreeResource -#include <winsock.h> -#undef BOOL -#undef ATOM -#undef FreeResource -#undef CreateWindowA -#undef RT_FONT -#undef RT_CURSOR +#include <Xwinsock.h> #endif #include "Xos.h" @@ -1548,7 +1538,9 @@ get_addr_by_name( #ifdef XTHREADS_NEEDS_BYNAMEPARAMS _Xgethostbynameparams hparams; #endif - +#if defined(WIN32) && (defined(TCPCONN) || defined(DNETCONN)) + _XSERVTransWSAStartup(); +#endif if (!(hep = _XGethostbyname(namestr, hparams))) { FatalError("Xserver: %s unknown host: %s\n", argtype, namestr); diff --git a/render/picture.h b/render/picture.h index 4ed6e6ae0..e37c8b830 100644 --- a/render/picture.h +++ b/render/picture.h @@ -165,7 +165,7 @@ extern int RenderClientPrivateIndex; /* Fixed point updates from Carl Worth, USC, Information Sciences Institute */ -#ifdef WIN32 +#if defined(WIN32) && !defined(__GNUC__) typedef __int64 xFixed_32_32; #else # if defined (_LP64) || \ diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c index 636882955..f346afd78 100644 --- a/xkb/ddxLoad.c +++ b/xkb/ddxLoad.c @@ -71,6 +71,19 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #define POST_ERROR_MSG1 "\"Errors from xkbcomp are not fatal to the X server\"" #define POST_ERROR_MSG2 "\"End of messages from xkbcomp\"" +#ifdef WIN32 +static const char* +Win32TempDir() +{ + if (getenv("TEMP") != NULL) + return getenv("TEMP"); + else if (getenv("TMP") != NULL) + return getenv("TEMP"); + else + return "/tmp"; +} +#endif + static void OutputDirectory( char* outdir) @@ -88,7 +101,12 @@ OutputDirectory( if (outdir[strlen(outdir) - 1] != '/') /* Hi IBM, Digital */ (void) strcat (outdir, "/"); #else +#ifndef WIN32 (void) strcpy (outdir, "/tmp/"); +#else + strcpy(outdir, Win32TempDir()); + strcat(outdir, "\\"); +#endif #endif } } @@ -196,7 +214,7 @@ char cmd[PATH_MAX],file[PATH_MAX],xkm_output_dir[PATH_MAX],*map,*outFile; _XkbFree(outFile); return False; } - + Bool XkbDDXCompileKeymapByNames( XkbDescPtr xkb, XkbComponentNamesPtr names, @@ -208,7 +226,7 @@ XkbDDXCompileKeymapByNames( XkbDescPtr xkb, FILE * out; char buf[PATH_MAX],keymap[PATH_MAX],xkm_output_dir[PATH_MAX]; #ifdef WIN32 -char tmpname[32]; +char tmpname[MAX_PATH]; #endif #ifdef __UNIXOS2__ char *tmpbase; @@ -228,7 +246,8 @@ int i; XkbEnsureSafeMapName(keymap); OutputDirectory(xkm_output_dir); #ifdef WIN32 - strcpy(tmpname, "\\temp\\xkb_XXXXXX"); + strcpy(tmpname, Win32TempDir()); + strcat(tmpname, "\\xkb_XXXXXX"); (void) mktemp(tmpname); #endif #ifdef __UNIXOS2__ @@ -387,7 +406,11 @@ FILE * file; buf[0]= '\0'; if (mapName!=NULL) { OutputDirectory(xkm_output_dir); - if ((XkbBaseDirectory!=NULL)&&(xkm_output_dir[0]!='/')) { + if ((XkbBaseDirectory!=NULL)&&(xkm_output_dir[0]!='/') +#ifdef WIN32 + &&(!isalpha(xkm_output_dir[0]) || xkm_output_dir[1]!=':') +#endif + ) { if (strlen(XkbBaseDirectory)+strlen(xkm_output_dir) +strlen(mapName)+6 <= PATH_MAX) { |