summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac16
-rw-r--r--glx/Makefile.am2
-rw-r--r--hw/xwin/InitOutput.c102
-rw-r--r--hw/xwin/Makefile.am1
-rwxr-xr-xhw/xwin/XWin.exe.manifest5
-rw-r--r--hw/xwin/XWin.rc2
-rw-r--r--hw/xwin/win.h9
-rw-r--r--hw/xwin/winblock.c23
-rw-r--r--hw/xwin/winclipboardthread.c36
-rw-r--r--hw/xwin/winclipboardwndproc.c48
-rwxr-xr-xhw/xwin/windialogs.c2
-rw-r--r--hw/xwin/windisplay.c56
-rw-r--r--hw/xwin/winerror.c17
-rw-r--r--hw/xwin/winmultiwindowwindow.c3
-rw-r--r--hw/xwin/winmultiwindowwm.c32
-rw-r--r--hw/xwin/winmultiwindowwndproc.c12
-rw-r--r--hw/xwin/winprefs.c85
-rw-r--r--hw/xwin/winprefslex.l10
-rwxr-xr-xhw/xwin/winprocarg.c23
-rw-r--r--hw/xwin/winwakeup.c4
-rw-r--r--include/os.h2
-rw-r--r--os/connection.c17
-rw-r--r--os/log.c2
-rw-r--r--os/utils.c2
24 files changed, 297 insertions, 214 deletions
diff --git a/configure.ac b/configure.ac
index b48d3a9c5..886419593 100644
--- a/configure.ac
+++ b/configure.ac
@@ -77,7 +77,7 @@ AC_PROG_LEX
AC_PROG_YACC
AC_SYS_LARGEFILE
XORG_PROG_RAWCPP
-AC_PATH_PROG(SED,sed)
+AC_PROG_SED
# Quoted so that make will expand $(CWARNFLAGS) in makefiles to allow
# easier overrides at build time.
@@ -615,7 +615,7 @@ AC_ARG_ENABLE(registry, AS_HELP_STRING([--disable-registry], [Build string
AC_ARG_ENABLE(composite, AS_HELP_STRING([--disable-composite], [Build Composite extension (default: enabled)]), [COMPOSITE=$enableval], [COMPOSITE=yes])
AC_ARG_ENABLE(mitshm, AS_HELP_STRING([--disable-shm], [Build SHM extension (default: enabled)]), [MITSHM=$enableval], [MITSHM=yes])
AC_ARG_ENABLE(xres, AS_HELP_STRING([--disable-xres], [Build XRes extension (default: enabled)]), [RES=$enableval], [RES=yes])
-AC_ARG_ENABLE(record, AS_HELP_STRING([--enable-record], [Build Record extension (default: disabled)]), [RECORD=$enableval], [RECORD=no])
+AC_ARG_ENABLE(record, AS_HELP_STRING([--disable-record], [Build Record extension (default: enabled)]), [RECORD=$enableval], [RECORD=yes])
AC_ARG_ENABLE(xv, AS_HELP_STRING([--disable-xv], [Build Xv extension (default: enabled)]), [XV=$enableval], [XV=yes])
AC_ARG_ENABLE(xvmc, AS_HELP_STRING([--disable-xvmc], [Build XvMC extension (default: enabled)]), [XVMC=$enableval], [XVMC=yes])
AC_ARG_ENABLE(dga, AS_HELP_STRING([--disable-dga], [Build DGA extension (default: auto)]), [DGA=$enableval], [DGA=auto])
@@ -994,7 +994,7 @@ if test "x$GLX" = xyes; then
AC_SUBST(XLIB_CFLAGS)
AC_DEFINE(GLXEXT, 1, [Build GLX extension])
GLX_LIBS='$(top_builddir)/glx/libglx.la'
- GLX_SYS_LIBS="$GLX_SYS_LIBS"
+ GLX_SYS_LIBS="$GLX_SYS_LIBS $GL_LIBS"
else
GLX=no
fi
@@ -1167,8 +1167,8 @@ fi
dnl XKM_OUTPUT_DIR (used in code) must end in / or file names get hosed
dnl XKB_COMPILED_DIR (used in Makefiles) must not or install-sh gets confused
-XKBOUTPUT=`echo $XKBOUTPUT/ | sed 's|/*$|/|'`
-XKB_COMPILED_DIR=`echo $XKBOUTPUT | sed 's|/*$||'`
+XKBOUTPUT=`echo $XKBOUTPUT/ | $SED 's|/*$|/|'`
+XKB_COMPILED_DIR=`echo $XKBOUTPUT | $SED 's|/*$||'`
AC_DEFINE_DIR(XKM_OUTPUT_DIR, XKBOUTPUT, [Path to XKB output dir])
AC_SUBST(XKB_COMPILED_DIR)
@@ -1646,11 +1646,11 @@ if test "x$XORG" = xyes; then
AC_CHECK_HEADERS([sys/vt.h], [solaris_vt=yes], [solaris_vt=no])
# Check for minimum supported release
AC_MSG_CHECKING([Solaris version])
- OS_MINOR=`echo ${host_os}|sed -e 's/^.*solaris2\.//' -e s'/\..*$//'`
+ OS_MINOR=`echo ${host_os}|$SED -e 's/^.*solaris2\.//' -e s'/\..*$//'`
if test "${OS_MINOR}" -ge 7 ; then
AC_MSG_RESULT(Solaris ${OS_MINOR})
else
- AC_MSG_RESULT(Solaris `echo ${host_os}|sed -e 's/^.*solaris//`)
+ AC_MSG_RESULT(Solaris `echo ${host_os}|$SED -e 's/^.*solaris//`)
fi
if test "${OS_MINOR}" -lt 8 ; then
AC_MSG_ERROR([This release no longer supports Solaris versions older than Solaris 8.])
@@ -1869,7 +1869,7 @@ if test "x$XWIN" = xyes; then
;;
esac
XWIN_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $RANDR_LIB $RENDER_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $OS_LIB"
- XWIN_SYS_LIBS="$XWIN_SYS_LIBS $XWINMODULES_LIBS"
+ XWIN_SYS_LIBS="$XWIN_SYS_LIBS $XWINMODULES_LIBS $GLX_SYS_LIBS"
AC_SUBST(XWIN_LIBS)
AC_SUBST(XWIN_SERVER_NAME)
AC_SUBST(XWIN_SYS_LIBS)
diff --git a/glx/Makefile.am b/glx/Makefile.am
index 9d9fa3c31..eb0c53335 100644
--- a/glx/Makefile.am
+++ b/glx/Makefile.am
@@ -42,11 +42,9 @@ glapi_sources = \
dispatch.h \
glapitable.h \
glapitemp.h \
- glapi.c \
glapi.h \
glapioffsets.h \
glprocs.h \
- glthread.c \
glthread.h
libglxdri_la_SOURCES = \
diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index fd286de44..002b14581 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -31,6 +31,8 @@ from The Open Group.
#ifdef HAVE_XWIN_CONFIG_H
#include <xwin-config.h>
#endif
+/* GLX debugging helpers */
+#include <../glx/glapi.h>
#include "win.h"
#include "winmsg.h"
#include "winconfig.h"
@@ -118,9 +120,6 @@ OsVendorVErrorF (const char *pszFormat, va_list va_args);
void
winInitializeDefaultScreens (void);
-static Bool
-winCheckDisplayNumber (void);
-
void
winLogCommandLine (int argc, char *argv[]);
@@ -135,6 +134,9 @@ const char *
winGetBaseDir(void);
#endif
+static
+void glx_debugging(void);
+
/*
* For the depth 24 pixmap we default to 32 bits per pixel, but
* we change this pixmap format later if we detect that the display
@@ -961,15 +963,6 @@ InitOutput (ScreenInfo *screenInfo, int argc, char *argv[])
"Exiting.\n");
}
- /* Check for duplicate invocation on same display number.*/
- if (serverGeneration == 1 && !winCheckDisplayNumber ())
- {
- if (g_fSilentDupError)
- g_fSilentFatalError = TRUE;
- FatalError ("InitOutput - Duplicate invocation on display "
- "number: %s. Exiting.\n", display);
- }
-
#ifdef XWIN_XF86CONFIG
/* Try to read the xorg.conf-style configuration file */
if (!winReadConfigfile ())
@@ -1051,6 +1044,8 @@ InitOutput (ScreenInfo *screenInfo, int argc, char *argv[])
* Apply locale specified in LANG environment variable.
*/
setlocale (LC_ALL, "");
+
+ glx_debugging();
}
#endif
@@ -1059,77 +1054,18 @@ InitOutput (ScreenInfo *screenInfo, int argc, char *argv[])
#endif
}
+static
+void warn_func(void * p1, const char *format, ...) {
+ va_list v;
+ va_start(v, format);
+ vfprintf(stderr, format, v);
+ va_end(v);
+ fprintf(stderr,"\n");
+}
-/*
- * winCheckDisplayNumber - Check if another instance of Cygwin/X is
- * already running on the same display number. If no one exists,
- * make a mutex to prevent new instances from running on the same display.
- *
- * return FALSE if the display number is already used.
- */
-
-static Bool
-winCheckDisplayNumber (void)
+static
+void glx_debugging(void)
{
- int nDisp;
- HANDLE mutex;
- char name[MAX_PATH];
- char * pszPrefix = '\0';
- OSVERSIONINFO osvi = {0};
-
- /* Check display range */
- nDisp = atoi (display);
- if (nDisp < 0 || nDisp > 65535)
- {
- ErrorF ("winCheckDisplayNumber - Bad display number: %d\n", nDisp);
- return FALSE;
- }
-
- /* Set first character of mutex name to null */
- name[0] = '\0';
-
- /* Get operating system version information */
- osvi.dwOSVersionInfoSize = sizeof (osvi);
- GetVersionEx (&osvi);
-
- /* Want a mutex shared among all terminals on NT > 4.0 */
- if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT
- && osvi.dwMajorVersion >= 5)
- {
- pszPrefix = "Global\\";
- }
-
- /* Setup Cygwin/X specific part of name */
- snprintf (name, sizeof(name), "%sCYGWINX_DISPLAY:%d", pszPrefix, nDisp);
-
- /* Windows automatically releases the mutex when this process exits */
- mutex = CreateMutex (NULL, FALSE, name);
- if (!mutex)
- {
- LPVOID lpMsgBuf;
-
- /* Display a fancy error message */
- FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- GetLastError (),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR) &lpMsgBuf,
- 0, NULL);
- ErrorF ("winCheckDisplayNumber - CreateMutex failed: %s\n",
- (LPSTR)lpMsgBuf);
- LocalFree (lpMsgBuf);
-
- return FALSE;
- }
- if (GetLastError () == ERROR_ALREADY_EXISTS)
- {
- ErrorF ("winCheckDisplayNumber - "
- PROJECT_NAME " is already running on display %d\n",
- nDisp);
- return FALSE;
- }
-
- return TRUE;
+ _glapi_set_warning_func(warn_func);
+ _glapi_noop_enable_warnings(TRUE);
}
diff --git a/hw/xwin/Makefile.am b/hw/xwin/Makefile.am
index 89b021b22..e901df62d 100644
--- a/hw/xwin/Makefile.am
+++ b/hw/xwin/Makefile.am
@@ -119,6 +119,7 @@ SRCS = InitInput.c \
winpriv.h \
winresource.h \
winwindow.h \
+ windisplay.c \
XWin.rc \
$(top_srcdir)/Xext/dpmsstubs.c \
$(top_srcdir)/Xi/stubs.c \
diff --git a/hw/xwin/XWin.exe.manifest b/hw/xwin/XWin.exe.manifest
index 221150d52..a0d4d7dae 100755
--- a/hw/xwin/XWin.exe.manifest
+++ b/hw/xwin/XWin.exe.manifest
@@ -13,4 +13,9 @@
/>
</dependentAssembly>
</dependency>
+ <asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
+ <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
+ <dpiAware>true</dpiAware>
+ </asmv3:windowsSettings>
+ </asmv3:application>
</assembly>
diff --git a/hw/xwin/XWin.rc b/hw/xwin/XWin.rc
index 539bd0e4d..a142f3070 100644
--- a/hw/xwin/XWin.rc
+++ b/hw/xwin/XWin.rc
@@ -50,7 +50,7 @@ BEGIN
LTEXT BUILDERSTRING, IDC_STATIC, 36, 28, 220, 8
LTEXT "This software is licensed under the terms of the MIT/X11 License.", IDC_STATIC, 36, 48, 220, 20
CONTROL __VENDORDWEBSUPPORT__, ID_ABOUT_WEBSITE, "Button",
- BS_OWNERDRAW | WS_TABSTOP, 36, 68, 68, 8
+ BS_OWNERDRAW | WS_TABSTOP, 36, 68, 220, 8
DEFPUSHBUTTON "&OK", IDOK, 105, 85, 50, 15
END
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index b1acd3e47..fdf9ff2b2 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -64,7 +64,7 @@
#define WIN_DEFAULT_BLACKPIXEL 0
#define WIN_DEFAULT_LINEBIAS 0
#define WIN_DEFAULT_E3B_TIME 50 /* milliseconds */
-#define WIN_DEFAULT_DPI 75
+#define WIN_DEFAULT_DPI 96
#define WIN_DEFAULT_REFRESH 0
#define WIN_DEFAULT_WIN_KILL TRUE
#define WIN_DEFAULT_UNIX_KILL FALSE
@@ -1451,6 +1451,13 @@ Bool
winInitCursor (ScreenPtr pScreen);
/*
+ * windisplay.c
+ */
+
+void
+winGetDisplayName(char *szDisplay, unsigned int screen);
+
+/*
* END DDX and DIX Function Prototypes
*/
diff --git a/hw/xwin/winblock.c b/hw/xwin/winblock.c
index abea60e0f..bdf0a2408 100644
--- a/hw/xwin/winblock.c
+++ b/hw/xwin/winblock.c
@@ -54,7 +54,7 @@ winBlockHandler (int nScreen,
#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
winScreenPriv((ScreenPtr)pBlockData);
#endif
- MSG msg;
+
#ifndef HAS_DEVWINDOWS
struct timeval **tvp = pTimeout;
if (*tvp != NULL)
@@ -81,26 +81,11 @@ winBlockHandler (int nScreen,
{
ErrorF ("winBlockHandler - pthread_mutex_unlock () failed: %d\n",
iReturn);
- goto winBlockHandler_ProcessMessages;
}
-
- winDebug ("winBlockHandler - pthread_mutex_unlock () returned\n");
- }
-
-winBlockHandler_ProcessMessages:
-#endif
-
- /* Process all messages on our queue */
- while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
- {
- if ((g_hDlgDepthChange == 0
- || !IsDialogMessage (g_hDlgDepthChange, &msg))
- && (g_hDlgExit == 0
- || !IsDialogMessage (g_hDlgExit, &msg))
- && (g_hDlgAbout == 0
- || !IsDialogMessage (g_hDlgAbout, &msg)))
+ else
{
- DispatchMessage (&msg);
+ winDebug ("winBlockHandler - pthread_mutex_unlock () returned\n");
}
}
+#endif
}
diff --git a/hw/xwin/winclipboardthread.c b/hw/xwin/winclipboardthread.c
index 5d2b9487e..9788d883b 100644
--- a/hw/xwin/winclipboardthread.c
+++ b/hw/xwin/winclipboardthread.c
@@ -72,6 +72,8 @@ winClipboardErrorHandler (Display *pDisplay, XErrorEvent *pErr);
static int
winClipboardIOErrorHandler (Display *pDisplay);
+static void
+winClipboardThreadExit(void *arg);
/*
* Main thread function
@@ -98,6 +100,8 @@ winClipboardProc (void *pvNotUsed)
char szDisplay[512];
int iSelectError;
+ pthread_cleanup_push(&winClipboardThreadExit, NULL);
+
ErrorF ("winClipboardProc - Hello\n");
/* Do we have Unicode support? */
@@ -136,9 +140,9 @@ winClipboardProc (void *pvNotUsed)
}
else if (iReturn == WIN_JMP_ERROR_IO)
{
- /* TODO: Cleanup the Win32 window and free any allocated memory */
- ErrorF ("winClipboardProc - setjmp returned for IO Error Handler.\n");
- pthread_exit (NULL);
+ /* TODO: cleanup and free any allocated memory */
+ ErrorF("winClipboardProc - setjmp returned for IO Error Handler\n");
+ goto winClipboardProc_Done;
}
/* Use our generated cookie for authentication */
@@ -159,10 +163,7 @@ winClipboardProc (void *pvNotUsed)
* for all screens on the display. That is why there is only
* one clipboard client thread.
*/
- snprintf (szDisplay,
- 512,
- "127.0.0.1:%s.0",
- display);
+ winGetDisplayName(szDisplay, 0);
/* Print the display connection string */
ErrorF ("winClipboardProc - DISPLAY=%s\n", szDisplay);
@@ -192,7 +193,7 @@ winClipboardProc (void *pvNotUsed)
pthread_exit (NULL);
}
- /* Save the display in the screen privates */
+ /* Save the display in a global used by the wndproc */
g_pClipboardDisplay = pDisplay;
ErrorF ("winClipboardProc - XOpenDisplay () returned and "
@@ -287,7 +288,10 @@ winClipboardProc (void *pvNotUsed)
/* Pre-flush Windows messages */
if (!winClipboardFlushWindowsMessageQueue (hwnd))
- return 0;
+ {
+ ErrorF ("winClipboardProc - winClipboardFlushWindowsMessageQueue failed\n");
+ pthread_exit (NULL);
+ }
/* Signal that the clipboard client has started */
g_fClipboardStarted = TRUE;
@@ -377,6 +381,7 @@ winClipboardProc (void *pvNotUsed)
}
}
+winClipboardProc_Done:
/* Close our X window */
if (pDisplay && iWindow)
{
@@ -419,6 +424,8 @@ winClipboardProc (void *pvNotUsed)
g_pClipboardDisplay = NULL;
g_hwndClipboard = NULL;
+ pthread_cleanup_pop(0);
+
return NULL;
}
@@ -460,3 +467,14 @@ winClipboardIOErrorHandler (Display *pDisplay)
return 0;
}
+
+/*
+ * winClipboardThreadExit - Thread exit handler
+ */
+
+static void
+winClipboardThreadExit(void *arg)
+{
+ /* clipboard thread has exited, stop server as well */
+ kill(getpid(), SIGTERM);
+}
diff --git a/hw/xwin/winclipboardwndproc.c b/hw/xwin/winclipboardwndproc.c
index 9394b04db..03da7f41c 100644
--- a/hw/xwin/winclipboardwndproc.c
+++ b/hw/xwin/winclipboardwndproc.c
@@ -56,8 +56,6 @@ extern void *g_pClipboardDisplay;
extern Window g_iClipboardWindow;
extern Atom g_atomLastOwnedSelection;
-/* BPS - g_hwndClipboard needed for X app->Windows paste fix */
-extern HWND g_hwndClipboard;
/*
* Local function prototypes
@@ -143,12 +141,6 @@ winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
* Process a given Windows message
*/
-/* BPS - Define our own message, which we'll post to ourselves to facilitate
- * resetting the delayed rendering mechanism after each paste from X app to
- * Windows app. TODO - Perhaps move to win.h with the other WM_USER messages.
- */
-#define WM_USER_PASTE_COMPLETE (WM_USER + 1003)
-
LRESULT CALLBACK
winClipboardWindowProc (HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
@@ -343,6 +335,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);
@@ -540,13 +534,6 @@ winClipboardWindowProc (HWND hwnd, UINT message,
ErrorF("winClipboardWindowProc - timed out waiting for WIN_XEVENTS_NOTIFY\n");
}
- /* BPS - Post ourselves a user message whose handler will reset the
- * delayed rendering mechanism after the paste is complete. This is
- * necessary because calling SetClipboardData() with a NULL argument
- * here will cause the data we just put on the clipboard to be lost!
- */
- PostMessage(g_hwndClipboard, WM_USER_PASTE_COMPLETE, 0, 0);
-
/* Special handling for WM_RENDERALLFORMATS */
if (message == WM_RENDERALLFORMATS)
{
@@ -564,37 +551,6 @@ winClipboardWindowProc (HWND hwnd, UINT message,
winDebug ("winClipboardWindowProc - WM_RENDER*FORMAT - Returning.\n");
return 0;
}
- /* BPS - This WM_USER message is posted by us. It gives us the opportunity
- * to reset the delayed rendering mechanism after each and every paste
- * from an X app to a Windows app. Without such a mechanism, subsequent
- * changes of selection in the X app owning the selection are not
- * reflected in pastes into Windows apps, since Windows won't send us the
- * WM_RENDERFORMAT message unless someone has set changed data (or NULL)
- * on the clipboard. */
- case WM_USER_PASTE_COMPLETE:
- {
- if (hwnd != GetClipboardOwner ())
- /* In case we've lost the selection since posting the message */
- return 0;
- winDebug ("winClipboardWindowProc - WM_USER_PASTE_COMPLETE\n");
-
- /* Set up for another delayed rendering callback */
- OpenClipboard (g_hwndClipboard);
-
- /* Take ownership of the Windows clipboard */
- EmptyClipboard ();
-
- /* Advertise Unicode if we support it */
- if (g_fUnicodeSupport)
- SetClipboardData (CF_UNICODETEXT, NULL);
-
- /* Always advertise regular text */
- SetClipboardData (CF_TEXT, NULL);
-
- /* Release the clipboard */
- CloseClipboard ();
- }
- return 0;
}
/* Let Windows perform default processing for unhandled messages */
diff --git a/hw/xwin/windialogs.c b/hw/xwin/windialogs.c
index a8153535f..498d952a3 100755
--- a/hw/xwin/windialogs.c
+++ b/hw/xwin/windialogs.c
@@ -127,7 +127,7 @@ winDrawURLWindow (LPARAM lParam)
/* Draw it */
SetBkMode (draw->hDC, OPAQUE);
SelectObject (draw->hDC, font);
- DrawText (draw->hDC, str, strlen (str),&rect,DT_CENTER | DT_VCENTER);
+ DrawText (draw->hDC, str, strlen (str),&rect,DT_LEFT | DT_VCENTER);
/* Delete the created font, replace it with stock font */
DeleteObject (SelectObject (draw->hDC, GetStockObject (ANSI_VAR_FONT)));
}
diff --git a/hw/xwin/windisplay.c b/hw/xwin/windisplay.c
new file mode 100644
index 000000000..ce111abda
--- /dev/null
+++ b/hw/xwin/windisplay.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) Jon TURNEY 2009
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include <opaque.h> // for display
+#include "win.h"
+
+/*
+ Generate a display name string referring to the display of this server,
+ using a transport we know is enabled
+*/
+
+void
+winGetDisplayName(char *szDisplay, unsigned int screen)
+{
+ if (TransIsListening("local"))
+ {
+ snprintf(szDisplay, 512, ":%s.%d", display, screen);
+ }
+ else if (TransIsListening("inet"))
+ {
+ snprintf(szDisplay, 512, "127.0.0.1:%s.%d", display, screen);
+ }
+ else if (TransIsListening("inet6"))
+ {
+ snprintf(szDisplay, 512, "::1:%s.%d", display, screen);
+ }
+ else
+ {
+ // this can't happen!
+ ErrorF ("winGetDisplay: Don't know what to use for DISPLAY\n");
+ snprintf(szDisplay, 512, "localhost:%s.%d", display, screen);
+ }
+
+ ErrorF ("winGetDisplay: DISPLAY=%s\n", szDisplay);
+}
diff --git a/hw/xwin/winerror.c b/hw/xwin/winerror.c
index 191b9a921..d87b68758 100644
--- a/hw/xwin/winerror.c
+++ b/hw/xwin/winerror.c
@@ -42,6 +42,7 @@
/* References to external symbols */
extern char * g_pszCommandLine;
extern const char * g_pszLogFile;
+extern Bool g_fSilentDupError;
extern Bool g_fSilentFatalError;
extern Bool g_fLogInited;
@@ -63,6 +64,22 @@ OsVendorVErrorF (const char *pszFormat, va_list va_args)
pthread_mutex_lock (&s_pmPrinting);
#endif
+ /* If we want to silence it,
+ * detect if we are going to abort due to duplication error */
+ if (g_fSilentDupError)
+ {
+ if ((strcmp(pszFormat,
+ "InitOutput - Duplicate invocation on display "
+ "number: %s. Exiting.\n") == 0)
+ || (strcmp(pszFormat,
+ "Server is already active for display %s\n%s %s\n%s\n") == 0)
+ || (strcmp(pszFormat,
+ "MakeAllCOTSServerListeners: server already running\n") == 0))
+ {
+ g_fSilentFatalError = TRUE;
+ }
+ }
+
/* Print the error message to a log file, could be stderr */
LogVWrite (0, pszFormat, va_args);
diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c
index 87ffc6d6b..fd87c6692 100644
--- a/hw/xwin/winmultiwindowwindow.c
+++ b/hw/xwin/winmultiwindowwindow.c
@@ -563,7 +563,6 @@ winCreateWindowsWindow (WindowPtr pWin)
ErrorF ("winCreateWindowsWindow - CreateWindowExA () failed: %d\n",
(int) GetLastError ());
}
- pWinPriv->hWnd = hWnd;
/* Set application or .XWinrc defined Icons */
winSelectIcons(pWin, &hIcon, &hIconSmall);
@@ -577,6 +576,8 @@ winCreateWindowsWindow (WindowPtr pWin)
/* Make sure it gets the proper system menu for a WS_POPUP, too */
GetSystemMenu (hWnd, TRUE);
+ pWinPriv->hWnd = hWnd;
+
/* Cause any .XWinrc menus to be added in main WNDPROC */
PostMessage (hWnd, WM_INIT_SYS_MENU, 0, 0);
diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c
index 2fcad3249..6c2812c6f 100644
--- a/hw/xwin/winmultiwindowwm.c
+++ b/hw/xwin/winmultiwindowwm.c
@@ -136,7 +136,6 @@ typedef struct _XMsgProcArgRec {
* References to external symbols
*/
-extern char *display;
extern void ErrorF (const char* /*f*/, ...);
/*
@@ -179,6 +178,9 @@ winMultiWindowXMsgProcErrorHandler (Display *pDisplay, XErrorEvent *pErr);
static int
winMultiWindowXMsgProcIOErrorHandler (Display *pDisplay);
+static void
+winMultiWindowThreadExit(void *arg);
+
static int
winRedirectErrorHandler (Display *pDisplay, XErrorEvent *pErr);
@@ -626,6 +628,8 @@ winMultiWindowWMProc (void *pArg)
{
WMProcArgPtr pProcArg = (WMProcArgPtr)pArg;
WMInfoPtr pWMInfo = pProcArg->pWMInfo;
+
+ pthread_cleanup_push(&winMultiWindowThreadExit, NULL);
/* Initialize the Window Manager */
winInitMultiWindowWM (pWMInfo, pProcArg);
@@ -838,6 +842,9 @@ winMultiWindowWMProc (void *pArg)
#if CYGMULTIWINDOW_DEBUG
ErrorF("-winMultiWindowWMProc ()\n");
#endif
+
+ pthread_cleanup_pop(0);
+
return NULL;
}
@@ -860,6 +867,8 @@ winMultiWindowXMsgProc (void *pArg)
int iReturn;
XIconSize *xis;
+ pthread_cleanup_push(&winMultiWindowThreadExit, NULL);
+
ErrorF ("winMultiWindowXMsgProc - Hello\n");
/* Check that argument pointer is not invalid */
@@ -924,8 +933,7 @@ winMultiWindowXMsgProc (void *pArg)
XSetIOErrorHandler (winMultiWindowXMsgProcIOErrorHandler);
/* Setup the display connection string x */
- snprintf (pszDisplay,
- 512, "127.0.0.1:%s.%d", display, (int)pProcArg->dwScreen);
+ winGetDisplayName(pszDisplay, (int)pProcArg->dwScreen);
/* Print the display connection string */
ErrorF ("winMultiWindowXMsgProc - DISPLAY=%s\n", pszDisplay);
@@ -1152,7 +1160,7 @@ winMultiWindowXMsgProc (void *pArg)
}
XCloseDisplay (pProcArg->pDisplay);
- pthread_exit (NULL);
+ pthread_cleanup_pop(0);
return NULL;
}
@@ -1307,11 +1315,7 @@ winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg)
XSetIOErrorHandler (winMultiWindowWMIOErrorHandler);
/* Setup the display connection string x */
- snprintf (pszDisplay,
- 512,
- "127.0.0.1:%s.%d",
- display,
- (int) pProcArg->dwScreen);
+ winGetDisplayName(pszDisplay, (int)pProcArg->dwScreen);
/* Print the display connection string */
ErrorF ("winInitMultiWindowWM - DISPLAY=%s\n", pszDisplay);
@@ -1478,6 +1482,16 @@ winMultiWindowXMsgProcIOErrorHandler (Display *pDisplay)
return 0;
}
+/*
+ * winMultiWindowThreadExit - Thread exit handler
+ */
+
+static void
+winMultiWindowThreadExit(void *arg)
+{
+ /* multiwindow client thread has exited, stop server as well */
+ kill(getpid(), SIGTERM);
+}
/*
* Catch RedirectError to detect other window manager running
diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c
index d14ceee9c..3df104eac 100644
--- a/hw/xwin/winmultiwindowwndproc.c
+++ b/hw/xwin/winmultiwindowwndproc.c
@@ -1015,8 +1015,20 @@ winTopLevelWindowProc (HWND hwnd, UINT message,
#endif
/* Adjust the X Window to the moved Windows window */
winAdjustXWindow (pWin, hwnd);
+ if (wParam == SIZE_MINIMIZED) winReorderWindowsMultiWindow();
return 0; /* end of WM_SIZE handler */
+ case WM_STYLECHANGED:
+ /* when the style changes, adjust the window size so the client area remains the same */
+ {
+ LONG x,y;
+ DrawablePtr pDraw = &pWin->drawable;
+ x = pDraw->x - wBorderWidth(pWin);
+ y = pDraw->y - wBorderWidth(pWin);
+ winPositionWindowMultiWindow(pWin, x, y);
+ }
+ return 0;
+
case WM_MOUSEACTIVATE:
/* Check if this window needs to be made active when clicked */
diff --git a/hw/xwin/winprefs.c b/hw/xwin/winprefs.c
index 93901cac7..745e4ed12 100644
--- a/hw/xwin/winprefs.c
+++ b/hw/xwin/winprefs.c
@@ -56,8 +56,8 @@ extern DWORD g_dwCurrentThreadID;
extern const char *winGetBaseDir(void);
-/* From winmultiwindowflex.l, the real parser */
-extern void parse_file (FILE *fp);
+/* From winprefslex.l, the real parser */
+extern int parse_file (FILE *fp);
/* From winprefyacc.y, the pref structure loaded by the parser */
extern WINPREFS pref;
@@ -69,10 +69,6 @@ extern HICON g_hSmallIconX;
/* Currently in use command ID, incremented each new menu item created */
static int g_cmdid = STARTMENUID;
-
-/* Defined in DIX */
-extern char *display;
-
/* Local function to handle comma-ified icon names */
static HICON
LoadImageComma (char *fname, int sx, int sy, int flags);
@@ -723,6 +719,54 @@ winIconIsOverride(unsigned hiconIn)
/*
+ * Open and parse the XWinrc config file @path.
+ * If @path is NULL, use the built-in default.
+ */
+static int
+winPrefsLoadPreferences (char *path)
+{
+ FILE *prefFile = NULL;
+
+ if (path)
+ prefFile = fopen (path, "r");
+ else
+ {
+ char defaultPrefs[] =
+ "MENU rmenu {\n"
+ " \"How to customize this menu\" EXEC \"xterm +tb -e man XWinrc\"\n"
+ " \"Launch xterm\" EXEC xterm\n"
+ " \"Load .XWinrc\" RELOAD\n"
+ " SEPARATOR\n"
+ "}\n"
+ "\n"
+ "ROOTMENU rmenu\n";
+
+ path = "built-in default";
+ prefFile = fmemopen(defaultPrefs, strlen(defaultPrefs), "r");
+ }
+
+ if (!prefFile)
+ {
+ ErrorF ("LoadPreferences: %s not found\n", path);
+ return FALSE;
+ }
+
+ ErrorF ("LoadPreferences: Loading %s\n", path);
+
+ if((parse_file (prefFile)) != 0)
+ {
+ ErrorF ("LoadPreferences: %s is badly formed!\n", path);
+ fclose (prefFile);
+ return FALSE;
+ }
+
+ fclose (prefFile);
+ return TRUE;
+}
+
+
+
+/*
* Try and open ~/.XWinrc and system.XWinrc
* Load it into prefs structure for use by other functions
*/
@@ -731,16 +775,15 @@ LoadPreferences (void)
{
char *home;
char fname[PATH_MAX+NAME_MAX+2];
- FILE *prefFile;
char szDisplay[512];
char *szEnvDisplay;
int i, j;
char param[PARAM_MAX+1];
char *srcParam, *dstParam;
+ int parsed = FALSE;
/* First, clear all preference settings */
memset (&pref, 0, sizeof(pref));
- prefFile = NULL;
/* Now try and find a ~/.xwinrc file */
home = getenv ("HOME");
@@ -750,14 +793,11 @@ LoadPreferences (void)
if (fname[strlen(fname)-1]!='/')
strcat (fname, "/");
strcat (fname, ".XWinrc");
-
- prefFile = fopen (fname, "r");
- if (prefFile)
- ErrorF ("winPrefsLoadPreferences: %s\n", fname);
+ parsed = winPrefsLoadPreferences(fname);
}
/* No home file found, check system default */
- if (!prefFile)
+ if (!parsed)
{
char buffer[MAX_PATH];
#ifdef RELOCATE_PROJECTROOT
@@ -766,30 +806,27 @@ LoadPreferences (void)
strncpy(buffer, SYSCONFDIR"/X11/system.XWinrc", sizeof(buffer));
#endif
buffer[sizeof(buffer)-1] = 0;
- prefFile = fopen (buffer, "r");
- if (prefFile)
- ErrorF ("winPrefsLoadPreferences: %s\n", buffer);
+ parsed = winPrefsLoadPreferences(buffer);
}
- /* If we could open it, then read the settings and close it */
- if (prefFile)
+ /* Neither user nor system configuration found, or were badly formed */
+ if (!parsed)
{
- parse_file (prefFile);
- fclose (prefFile);
+ ErrorF ("LoadPreferences: See \"man XWinrc\" to customize the XWin menu.\n");
+ parsed = winPrefsLoadPreferences(NULL);
}
/* Setup a DISPLAY environment variable, need to allocate on heap */
/* because putenv doesn't copy the argument... */
- snprintf (szDisplay, 512, "DISPLAY=127.0.0.1:%s.0", display);
- szEnvDisplay = (char *)(malloc (strlen(szDisplay)+1));
+ winGetDisplayName(szDisplay, 0);
+ szEnvDisplay = (char *)(malloc(strlen(szDisplay)+strlen("DISPLAY=")+1));
if (szEnvDisplay)
{
- strcpy (szEnvDisplay, szDisplay);
+ snprintf(szEnvDisplay, 512, "DISPLAY=%s", szDisplay);
putenv (szEnvDisplay);
}
/* Replace any "%display%" in menu commands with display string */
- snprintf (szDisplay, 512, "127.0.0.1:%s.0", display);
for (i=0; i<pref.menuItems; i++)
{
for (j=0; j<pref.menu[i].menuItems; j++)
diff --git a/hw/xwin/winprefslex.l b/hw/xwin/winprefslex.l
index 463dff4ca..ba8aea696 100644
--- a/hw/xwin/winprefslex.l
+++ b/hw/xwin/winprefslex.l
@@ -113,14 +113,18 @@ yywrap (void)
/*
* Run a file through the yacc parser
*/
-void
+int
parse_file (FILE *file)
{
+ int ret;
+
if (!file)
- return;
+ return 1;
yylineno = 1;
yyin = file;
- yyparse ();
+ ret = yyparse ();
+ yylex_destroy ();
+ return ret;
}
diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c
index 66da76f6c..950e6b81e 100755
--- a/hw/xwin/winprocarg.c
+++ b/hw/xwin/winprocarg.c
@@ -157,12 +157,27 @@ winInitializeDefaultScreens (void)
dwWidth = GetSystemMetrics (SM_CXSCREEN);
dwHeight = GetSystemMetrics (SM_CYSCREEN);
- winErrorFVerb (2, "winInitializeDefaultScreens - w %d h %d\n",
- (int) dwWidth, (int) dwHeight);
+ winErrorFVerb(2, "winInitializeDefaultScreens - primary monitor w %d h %d\n", (int) dwWidth, (int) dwHeight);
- /* Set a default DPI, if no parameter was passed */
+ /* Set a default DPI, if no '-dpi' option was used */
if (monitorResolution == 0)
- monitorResolution = WIN_DEFAULT_DPI;
+ {
+ HDC hdc = GetDC(NULL);
+ if (hdc)
+ {
+ int dpiX = GetDeviceCaps(hdc, LOGPIXELSX);
+ int dpiY = GetDeviceCaps(hdc, LOGPIXELSY);
+
+ winErrorFVerb(2, "winInitializeDefaultScreens - native DPI x %d y %d\n", dpiX, dpiY);
+ monitorResolution = dpiY;
+ ReleaseDC(NULL, hdc);
+ }
+ else
+ {
+ winErrorFVerb(1, "winInitializeDefaultScreens - Failed to retrieve native DPI, falling back to default of %d DPI\n", WIN_DEFAULT_DPI);
+ monitorResolution = WIN_DEFAULT_DPI;
+ }
+ }
for (i = 0; i < MAXSCREENS; ++i)
{
diff --git a/hw/xwin/winwakeup.c b/hw/xwin/winwakeup.c
index e1eece34a..411fbc08f 100644
--- a/hw/xwin/winwakeup.c
+++ b/hw/xwin/winwakeup.c
@@ -55,8 +55,8 @@ winWakeupHandler (int nScreen,
{
MSG msg;
- /* Process all messages on our queue */
- while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
+ /* Process one message from our queue */
+ if (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
{
if ((g_hDlgDepthChange == 0
|| !IsDialogMessage (g_hDlgDepthChange, &msg))
diff --git a/include/os.h b/include/os.h
index 453ab82c7..9054eed57 100644
--- a/include/os.h
+++ b/include/os.h
@@ -114,6 +114,8 @@ extern _X_EXPORT int WriteToClient(ClientPtr /*who*/, int /*count*/, const void*
extern _X_EXPORT void ResetOsBuffers(void);
+extern _X_EXPORT int TransIsListening(char *protocol);
+
extern _X_EXPORT void InitConnectionLimits(void);
extern _X_EXPORT void NotifyParentProcess(void);
diff --git a/os/connection.c b/os/connection.c
index 61ba72a80..479a76497 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -270,6 +270,23 @@ lookup_trans_conn (int fd)
return (NULL);
}
+int
+TransIsListening(char *protocol)
+{
+ /* look for this transport in the list of listeners */
+ int i;
+ for (i = 0; i < ListenTransCount; i++)
+ {
+ if (!strcmp(protocol, ListenTransConns[i]->transptr->TransName))
+ {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+
/* Set MaxClients and lastfdesc, and allocate ConnectionTranslation */
void
diff --git a/os/log.c b/os/log.c
index 37733158a..940b32f76 100644
--- a/os/log.c
+++ b/os/log.c
@@ -197,6 +197,8 @@ LogInit(const char *fname, const char *backup)
}
free(oldLog);
}
+ } else {
+ unlink(logFileName);
}
if ((logFile = fopen(logFileName, "w")) == NULL)
FatalError("Cannot open log file \"%s\"\n", logFileName);
diff --git a/os/utils.c b/os/utils.c
index 7ab7cc3db..2a13baabd 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -1167,7 +1167,7 @@ XNFstrdup(const char *s)
}
-#ifdef SIGVTALRM
+#if defined(SIGVTALRM) && !defined(__CYGWIN__)
#define SMART_SCHEDULE_POSSIBLE
#endif