diff --git a/hw/xwin/Makefile.am b/hw/xwin/Makefile.am index 4ee963227..326ffa03d 100644 --- a/hw/xwin/Makefile.am +++ b/hw/xwin/Makefile.am @@ -15,7 +15,7 @@ if XWIN_GLX_WINDOWS GLX_DIR = glx DEFS_GLX_WINDOWS = -DXWIN_GLX_WINDOWS XWIN_GLX_LIBS = $(top_builddir)/hw/xwin/glx/libXwinGLX.la -XWIN_GLX_LINK_FLAGS = -lopengl32 +XWIN_GLX_SYS_LIBS = -lopengl32 endif if XWIN_MULTIWINDOW @@ -27,7 +27,7 @@ SRCS_MULTIWINDOW = \ propertystore.h \ winSetAppUserModelID.c DEFS_MULTIWINDOW = -DXWIN_MULTIWINDOW -MULTIWINDOW_LIBS = -lshlwapi -lole32 +MULTIWINDOW_SYS_LIBS = -lshlwapi -lole32 endif if XWIN_MULTIWINDOWEXTWM @@ -126,6 +126,8 @@ SRCS = InitInput.c \ winprefs.h \ winresource.h \ winwindow.h \ + windisplay.c \ + windisplay.h \ XWin.rc \ $(top_srcdir)/mi/miinitext.c \ $(SRCS_CLIPBOARD) \ @@ -150,11 +152,28 @@ XWin_SOURCES = $(SRCS) AM_CPPFLAGS = -I$(top_srcdir)/miext/rootless XWIN_SYS_LIBS += -ldxguid -XWIN_LIBS += $(top_builddir)/pseudoramiX/libPseudoramiX.la \ - $(top_builddir)/Xext/libXextdpmsstubs.la \ - $(top_builddir)/Xi/libXistubs.la -XWin_DEPENDENCIES = $(MULTIWINDOWEXTWM_LIBS) $(XWIN_GLX_LIBS) $(XWIN_LIBS) $(XSERVER_LIBS) -XWin_LDADD = $(MULTIWINDOW_LIBS) $(MULTIWINDOWEXTWM_LIBS) $(XWIN_GLX_LIBS) $(XWIN_GLX_LINK_FLAGS) $(XWIN_LIBS) $(MAIN_LIB) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) $(XWIN_SYS_LIBS) + +XWIN_LIBS += \ + $(top_builddir)/pseudoramiX/libPseudoramiX.la \ + $(top_builddir)/Xext/libXextdpmsstubs.la \ + $(top_builddir)/Xi/libXistubs.la + +XWin_DEPENDENCIES = \ + $(MULTIWINDOWEXTWM_LIBS) \ + $(XWIN_GLX_LIBS) \ + $(XWIN_LIBS) \ + $(XSERVER_LIBS) + +XWin_LDADD = \ + $(MULTIWINDOWEXTWM_LIBS) \ + $(XWIN_GLX_LIBS) \ + $(XWIN_LIBS) \ + $(XSERVER_LIBS) \ + $(XWIN_GLX_SYS_LIBS) \ + $(XSERVER_SYS_LIBS) \ + $(XWIN_SYS_LIBS) \ + $(MULTIWINDOW_SYS_LIBS) + XWin_LDFLAGS = -mwindows -Wl,--disable-stdcall-fixup $(LD_EXPORT_SYMBOLS_FLAG) diff --git a/hw/xwin/glx/.gitignore b/hw/xwin/glx/.gitignore index 062fd8573..9684410ac 100644 --- a/hw/xwin/glx/.gitignore +++ b/hw/xwin/glx/.gitignore @@ -1,3 +1,6 @@ # ignore generated files -generated_gl_wrappers.c +diag.txt +generated_gl_shim.c +generated_gl_thunks.c +generated_gl_thunks.def generated_wgl_wrappers.c diff --git a/hw/xwin/glx/gen_gl_wrappers.py b/hw/xwin/glx/gen_gl_wrappers.py index cdbba638a..69ab1efa9 100755 --- a/hw/xwin/glx/gen_gl_wrappers.py +++ b/hw/xwin/glx/gen_gl_wrappers.py @@ -100,13 +100,16 @@ reg = Registry() tree = etree.parse(regFilename) reg.loadElementTree(tree) -allVersions = '.*' +if shim: + versions = '1\.[012]' +else: + versions = '.*' genOpts = CGeneratorOptions( apiname = prefix, profile = 'compatibility', - versions = allVersions, - emitversions = allVersions, + versions = versions, + emitversions = versions, defaultExtensions = prefix, # Default extensions for GL protectFile = protect, protectFeature = protect, @@ -257,7 +260,7 @@ class ThunkOutputGenerator(OutputGenerator): pass def beginFeature(self, interface, emit): OutputGenerator.beginFeature(self, interface, emit) - self.OldVersion = self.featureName.startswith('GL_VERSION_1_0') or self.featureName.startswith('GL_VERSION_1_1') + self.OldVersion = (self.featureName in ['GL_VERSION_1_0', 'GL_VERSION_1_1']) def endFeature(self): OutputGenerator.endFeature(self) def genType(self, typeinfo, name): @@ -355,7 +358,7 @@ class ShimOutputGenerator(OutputGenerator): pass def beginFeature(self, interface, emit): OutputGenerator.beginFeature(self, interface, emit) - self.OldVersion = self.featureName.startswith('GL_VERSION_1_0') or self.featureName.startswith('GL_VERSION_1_1') or self.featureName.startswith('GL_VERSION_1_2') or self.featureName.startswith('GL_ARB_imaging') or self.featureName.startswith('GL_ARB_multitexture') or self.featureName.startswith('GL_ARB_texture_compression') + self.OldVersion = (self.featureName in ['GL_VERSION_1_0', 'GL_VERSION_1_1', 'GL_VERSION_1_2', 'GL_ARB_imaging', 'GL_ARB_multitexture', 'GL_ARB_texture_compression']) def endFeature(self): OutputGenerator.endFeature(self) def genType(self, typeinfo, name): diff --git a/hw/xwin/glx/glwindows.h b/hw/xwin/glx/glwindows.h index 4f859b498..34ff24c24 100644 --- a/hw/xwin/glx/glwindows.h +++ b/hw/xwin/glx/glwindows.h @@ -28,6 +28,9 @@ * DEALINGS IN THE SOFTWARE. */ +#ifndef GLWINDOWS_H +#define GLWINDOWS_H + #include typedef struct { @@ -53,3 +56,5 @@ int glWinSelectImplementation(int native); #define GLWIN_TRACE_MSG(a, ...) #define GLWIN_DEBUG_MSG(a, ...) #endif + +#endif diff --git a/hw/xwin/glx/indirect.c b/hw/xwin/glx/indirect.c index 9bfaac03d..93cdb29d6 100644 --- a/hw/xwin/glx/indirect.c +++ b/hw/xwin/glx/indirect.c @@ -738,9 +738,6 @@ glxWinScreenProbe(ScreenPtr pScreen) __glXScreenInit(&screen->base, pScreen); - // Override the GL extensions string set by __glXScreenInit() - screen->base.GLextensions = strdup(gl_extensions); - // Generate the GLX extensions string (overrides that set by __glXScreenInit()) { unsigned int buffer_size = @@ -893,13 +890,6 @@ glxWinDrawableSwapBuffers(ClientPtr client, __GLXdrawable * base) ("glxWinSwapBuffers on drawable %p, last context %p (native ctx %p)", base, draw->drawContext, draw->drawContext->ctx); - /* - draw->drawContext->base.drawPriv will not be set if the context is not current anymore, - but if it is, it should point to this drawable.... - */ - assert((draw->drawContext->base.drawPriv == NULL) || - (draw->drawContext->base.drawPriv == base)); - dc = glxWinMakeDC(draw->drawContext, draw, &dc, &hwnd); if (dc == NULL) return GL_FALSE; @@ -1123,7 +1113,6 @@ glxWinSetPixelFormat(__GLXWinContext * gc, HDC hdc, int bppOverride, fbConfigToPixelFormatIndex(hdc, gc->base.config, drawableTypeOverride, winScreen); if (pixelFormat == 0) { - ErrorF("wglChoosePixelFormat error: %s\n", glxWinErrorMessage()); return FALSE; } @@ -1306,7 +1295,7 @@ glxWinDeferredCreateContext(__GLXWinContext * gc, __GLXWinDrawable * draw) glxWinScreen *winScreen; int pixelFormat; - // XXX: which DC are supposed to use??? + // XXX: which DC are we supposed to use??? HDC screenDC = GetDC(NULL); if (!(gc->base.config->drawableType & GLX_PBUFFER_BIT)) { @@ -1319,10 +1308,8 @@ glxWinDeferredCreateContext(__GLXWinContext * gc, __GLXWinDrawable * draw) pixelFormat = fbConfigToPixelFormatIndex(screenDC, gc->base.config, - GLX_DRAWABLE_PBUFFER, winScreen); + GLX_PBUFFER_BIT, winScreen); if (pixelFormat == 0) { - ErrorF("wglChoosePixelFormat error: %s\n", - glxWinErrorMessage()); return; } @@ -1761,7 +1748,7 @@ fbConfigToPixelFormatIndex(HDC hdc, __GLXconfig * mode, SET_ATTR_VALUE(WGL_SWAP_METHOD_ARB, WGL_SWAP_EXCHANGE_ARB); if (mode->swapMethod == GLX_SWAP_COPY_OML) - SET_ATTR_VALUE(WGL_SWAP_COPY_ARB, TRUE); + SET_ATTR_VALUE(WGL_SWAP_METHOD_ARB, WGL_SWAP_COPY_ARB); // XXX: this should probably be the other way around, but that messes up drawableTypeOverride if (mode->visualRating == GLX_SLOW_VISUAL_EXT) diff --git a/hw/xwin/glx/winpriv.c b/hw/xwin/glx/winpriv.c index 4f6e4ffd5..9b4baf381 100644 --- a/hw/xwin/glx/winpriv.c +++ b/hw/xwin/glx/winpriv.c @@ -51,7 +51,7 @@ winGetWindowInfo(WindowPtr pWin) if (pWinPriv->hWnd == NULL) { winCreateWindowsWindow(pWin); - ErrorF("winGetWindowInfo: forcing window to exist...\n"); + winDebug("winGetWindowInfo: forcing window to exist\n"); } if (pWinPriv->hWnd != NULL) { diff --git a/hw/xwin/winclipboardthread.c b/hw/xwin/winclipboardthread.c index 33595be7f..e70896081 100644 --- a/hw/xwin/winclipboardthread.c +++ b/hw/xwin/winclipboardthread.c @@ -38,6 +38,7 @@ #include #include #include "winclipboard.h" +#include "windisplay.h" #ifdef __CYGWIN__ #include #endif @@ -157,7 +158,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); diff --git a/hw/xwin/windisplay.c b/hw/xwin/windisplay.c new file mode 100644 index 000000000..17f0c7789 --- /dev/null +++ b/hw/xwin/windisplay.c @@ -0,0 +1,64 @@ +/* + * File: windisplay.c + * Purpose: Retrieve server display name + * + * 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. + * + */ + +#ifdef HAVE_XWIN_CONFIG_H +#include +#endif + +#include // for display +#include "windisplay.h" +#include "winmsg.h" + +#define XSERV_t +#define TRANS_SERVER +#include + +/* + 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 (_XSERVTransIsListening("local")) { + snprintf(szDisplay, 512, ":%s.%d", display, screen); + } + else if (_XSERVTransIsListening("inet")) { + snprintf(szDisplay, 512, "127.0.0.1:%s.%d", display, screen); + } + else if (_XSERVTransIsListening("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); + } + + winDebug("winGetDisplay: DISPLAY=%s\n", szDisplay); +} diff --git a/hw/xwin/windisplay.h b/hw/xwin/windisplay.h new file mode 100644 index 000000000..d1d4549bf --- /dev/null +++ b/hw/xwin/windisplay.h @@ -0,0 +1,34 @@ +/* + * File: windisplay.h + * Purpose: Interface to retrieve server display name + * + * 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. + * + */ + +#ifndef WINDISPLAY_H +#define WINDISPLAY_H + +void +winGetDisplayName(char *szDisplay, unsigned int screen); + +#endif /* !WINDISPLAY_H */ diff --git a/hw/xwin/winmsg.h b/hw/xwin/winmsg.h index b638f2cb3..6c96c4070 100644 --- a/hw/xwin/winmsg.h +++ b/hw/xwin/winmsg.h @@ -30,6 +30,8 @@ * Authors: Alexander Gottwald */ +#include + /* * Function prototypes */ diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c index 618e38121..e17a9502d 100644 --- a/hw/xwin/winmultiwindowwm.c +++ b/hw/xwin/winmultiwindowwm.c @@ -61,6 +61,7 @@ #include "pixmapstr.h" #include "windowstr.h" #include "winglobals.h" +#include "windisplay.h" #ifdef XWIN_MULTIWINDOWEXTWM #include @@ -1053,8 +1054,7 @@ winMultiWindowXMsgProc(void *pArg) } /* 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); @@ -1446,8 +1446,7 @@ winInitMultiWindowWM(WMInfoPtr pWMInfo, WMProcArgPtr pProcArg) } /* 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); diff --git a/hw/xwin/winprefs.c b/hw/xwin/winprefs.c index f386facdd..53abc163f 100644 --- a/hw/xwin/winprefs.c +++ b/hw/xwin/winprefs.c @@ -44,6 +44,7 @@ #include #include "winprefs.h" +#include "windisplay.h" #include "winmultiwindowclass.h" /* Where will the custom menu commands start counting from? */ @@ -712,15 +713,14 @@ LoadPreferences(void) /* 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++) { if (pref.menu[i].menuItem[j].cmd == CMD_EXEC) { diff --git a/hw/xwin/winshadddnl.c b/hw/xwin/winshadddnl.c index 55af5c383..cb326dc81 100644 --- a/hw/xwin/winshadddnl.c +++ b/hw/xwin/winshadddnl.c @@ -986,6 +986,10 @@ winRedrawScreenShadowDDNL(ScreenPtr pScreen) RECT rcSrc, rcDest; POINT ptOrigin; + /* Return immediately if we didn't get needed surfaces */ + if (!pScreenPriv->pddsPrimary4 || !pScreenPriv->pddsShadow4) + return; + /* Get the origin of the window in the screen coords */ ptOrigin.x = pScreenInfo->dwXOffset; ptOrigin.y = pScreenInfo->dwYOffset;