diff options
author | marha <marha@users.sourceforge.net> | 2015-04-20 22:42:55 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2015-04-20 22:42:55 +0200 |
commit | 934184bfecd402aae891b8740d788b486aa7269f (patch) | |
tree | c23fb0afd169dc6846ea23bda21260fcffd1e3e6 /xorg-server/hw | |
parent | 57dd848fb6dd7cf15820172e2abc9fb9de2b4268 (diff) | |
parent | 4ba9be2882d9f1567809edb0a31fcdf11320d41f (diff) | |
download | vcxsrv-934184bfecd402aae891b8740d788b486aa7269f.tar.gz vcxsrv-934184bfecd402aae891b8740d788b486aa7269f.tar.bz2 vcxsrv-934184bfecd402aae891b8740d788b486aa7269f.zip |
Merge remote-tracking branch 'origin/released'
Conflicts:
mesalib/src/mesa/main/.gitignore
mesalib/src/mesa/main/dlopen.h
xorg-server/hw/xwin/glx/gen_gl_wrappers.py
xorg-server/hw/xwin/win.h
xorg-server/hw/xwin/winengine.c
xorg-server/hw/xwin/winglobals.c
xorg-server/hw/xwin/winscrinit.c
xorg-server/hw/xwin/winshaddd.c
xorg-server/randr/rrxinerama.c
Diffstat (limited to 'xorg-server/hw')
26 files changed, 351 insertions, 1329 deletions
diff --git a/xorg-server/hw/kdrive/ephyr/ephyr_glamor_glx.c b/xorg-server/hw/kdrive/ephyr/ephyr_glamor_glx.c index 8fe751693..582e3af96 100644 --- a/xorg-server/hw/kdrive/ephyr/ephyr_glamor_glx.c +++ b/xorg-server/hw/kdrive/ephyr/ephyr_glamor_glx.c @@ -214,6 +214,8 @@ ephyr_glamor_damage_redisplay(struct ephyr_glamor *glamor, glBindFramebuffer(GL_FRAMEBUFFER, 0); glUseProgram(glamor->texture_shader); glViewport(0, 0, glamor->width, glamor->height); + if (!ephyr_glamor_gles2) + glDisable(GL_COLOR_LOGIC_OP); glVertexAttribPointer(glamor->texture_shader_position_loc, 2, GL_FLOAT, FALSE, 0, position); diff --git a/xorg-server/hw/kdrive/ephyr/hostx.c b/xorg-server/hw/kdrive/ephyr/hostx.c index 0baf35929..14d4a6c23 100755 --- a/xorg-server/hw/kdrive/ephyr/hostx.c +++ b/xorg-server/hw/kdrive/ephyr/hostx.c @@ -449,7 +449,7 @@ hostx_init(void) else #endif HostX.conn = xcb_connect(NULL, &HostX.screen); - if (xcb_connection_has_error(HostX.conn)) { + if (!HostX.conn || xcb_connection_has_error(HostX.conn)) { fprintf(stderr, "\nXephyr cannot open host display. Is DISPLAY set?\n"); exit(1); } @@ -1433,9 +1433,10 @@ ephyr_glamor_init(ScreenPtr screen) ephyr_glamor_set_window_size(scrpriv->glamor, scrpriv->win_width, scrpriv->win_height); - glamor_init(screen, - GLAMOR_USE_SCREEN | - GLAMOR_USE_PICTURE_SCREEN); + if (!glamor_init(screen, 0)) { + FatalError("Failed to initialize glamor\n"); + return FALSE; + } return TRUE; } diff --git a/xorg-server/hw/xfree86/common/xf86Events.c b/xorg-server/hw/xfree86/common/xf86Events.c index c06aaaee1..97a1f97b2 100644 --- a/xorg-server/hw/xfree86/common/xf86Events.c +++ b/xorg-server/hw/xfree86/common/xf86Events.c @@ -583,10 +583,11 @@ xf86VTEnter(void) /* Turn screen saver off when switching back */ dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset); - /* If we use systemd-logind it will enable input devices for us */ - if (!systemd_logind_controls_session()) - for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next) + for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next) { + /* Devices with server managed fds get enabled on logind resume */ + if (!(pInfo->flags & XI86_SERVER_FD)) xf86EnableInputDeviceForVTSwitch(pInfo); + } for (ih = InputHandlers; ih; ih = ih->next) { if (ih->is_input) diff --git a/xorg-server/hw/xfree86/common/xf86platformBus.c b/xorg-server/hw/xfree86/common/xf86platformBus.c index 15988b8b1..c1aaba41a 100644 --- a/xorg-server/hw/xfree86/common/xf86platformBus.c +++ b/xorg-server/hw/xfree86/common/xf86platformBus.c @@ -153,8 +153,10 @@ xf86_check_platform_slot(const struct xf86_platform_device *pd) for (i = 0; i < xf86NumEntities; i++) { const EntityPtr u = xf86Entities[i]; - if (pd->pdev && u->bus.type == BUS_PCI) - return !MATCH_PCI_DEVICES(pd->pdev, u->bus.id.pci); + if (pd->pdev && u->bus.type == BUS_PCI && + MATCH_PCI_DEVICES(pd->pdev, u->bus.id.pci)) { + return FALSE; + } if ((u->bus.type == BUS_PLATFORM) && (pd == u->bus.id.plat)) { return FALSE; } @@ -426,6 +428,10 @@ xf86platformProbeDev(DriverPtr drvp) /* find the main device or any device specificed in xorg.conf */ for (i = 0; i < numDevs; i++) { + /* skip inactive devices */ + if (!devList[i]->active) + continue; + for (j = 0; j < xf86_num_platform_devices; j++) { if (devList[i]->busID && *devList[i]->busID) { if (xf86PlatformDeviceCheckBusID(&xf86_platform_devices[j], devList[i]->busID)) @@ -449,10 +455,14 @@ xf86platformProbeDev(DriverPtr drvp) continue; } - /* if autoaddgpu devices is enabled then go find a few more and add them as GPU screens */ - if (xf86Info.autoAddGPU && numDevs) { + /* if autoaddgpu devices is enabled then go find any unclaimed platform + * devices and add them as GPU screens */ + if (xf86Info.autoAddGPU) { for (j = 0; j < xf86_num_platform_devices; j++) { - probeSingleDevice(&xf86_platform_devices[j], drvp, devList[0], PLATFORM_PROBE_GPU_SCREEN); + if (probeSingleDevice(&xf86_platform_devices[j], drvp, + devList ? devList[0] : NULL, + PLATFORM_PROBE_GPU_SCREEN)) + foundScreen = TRUE; } } diff --git a/xorg-server/hw/xfree86/drivers/modesetting/driver.c b/xorg-server/hw/xfree86/drivers/modesetting/driver.c index d52517d1a..e2f3846ca 100644 --- a/xorg-server/hw/xfree86/drivers/modesetting/driver.c +++ b/xorg-server/hw/xfree86/drivers/modesetting/driver.c @@ -1049,10 +1049,7 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv) #ifdef GLAMOR if (ms->drmmode.glamor) { - if (!glamor_init(pScreen, - GLAMOR_USE_EGL_SCREEN | - GLAMOR_USE_SCREEN | - GLAMOR_USE_PICTURE_SCREEN)) { + if (!glamor_init(pScreen, GLAMOR_USE_EGL_SCREEN)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to initialize glamor at ScreenInit() time.\n"); return FALSE; diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.c b/xorg-server/hw/xfree86/modes/xf86Crtc.c index 9d592a7eb..a1947241b 100644 --- a/xorg-server/hw/xfree86/modes/xf86Crtc.c +++ b/xorg-server/hw/xfree86/modes/xf86Crtc.c @@ -3026,6 +3026,27 @@ xf86OutputSetEDIDProperty(xf86OutputPtr output, void *data, int data_len) } } +#define TILE_ATOM_NAME "TILE" +/* changing this in the future could be tricky as people may hardcode 8 */ +#define TILE_PROP_NUM_ITEMS 8 +static void +xf86OutputSetTileProperty(xf86OutputPtr output) +{ + Atom tile_atom = MakeAtom(TILE_ATOM_NAME, sizeof(TILE_ATOM_NAME) - 1, TRUE); + + /* This may get called before the RandR resources have been created */ + if (output->randr_output == NULL) + return; + + if (output->tile_info.group_id != 0) { + RRChangeOutputProperty(output->randr_output, tile_atom, XA_INTEGER, 32, + PropModeReplace, TILE_PROP_NUM_ITEMS, (uint32_t *)&output->tile_info, FALSE, TRUE); + } + else { + RRDeleteOutputProperty(output->randr_output, tile_atom); + } +} + #endif /* Pull out a phyiscal size from a detailed timing if available. */ @@ -3071,6 +3092,38 @@ handle_detailed_physical_size(struct detailed_monitor_section } } +Bool +xf86OutputParseKMSTile(const char *tile_data, int tile_length, + struct xf86CrtcTileInfo *tile_info) +{ + int ret; + + ret = sscanf(tile_data, "%d:%d:%d:%d:%d:%d:%d:%d", + &tile_info->group_id, + &tile_info->flags, + &tile_info->num_h_tile, + &tile_info->num_v_tile, + &tile_info->tile_h_loc, + &tile_info->tile_v_loc, + &tile_info->tile_h_size, + &tile_info->tile_v_size); + if (ret != 8) + return FALSE; + return TRUE; +} + +void +xf86OutputSetTile(xf86OutputPtr output, struct xf86CrtcTileInfo *tile_info) +{ + if (tile_info) + output->tile_info = *tile_info; + else + memset(&output->tile_info, 0, sizeof(output->tile_info)); +#ifdef RANDR_12_INTERFACE + xf86OutputSetTileProperty(output); +#endif +} + /** * Set the EDID information for the specified output */ diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.h b/xorg-server/hw/xfree86/modes/xf86Crtc.h index 692bf40b9..3c5bbcfd5 100644 --- a/xorg-server/hw/xfree86/modes/xf86Crtc.h +++ b/xorg-server/hw/xfree86/modes/xf86Crtc.h @@ -70,6 +70,17 @@ typedef enum _xf86OutputStatus { XF86OutputStatusUnknown } xf86OutputStatus; +struct xf86CrtcTileInfo { + uint32_t group_id; + uint32_t flags; + uint32_t num_h_tile; + uint32_t num_v_tile; + uint32_t tile_h_loc; + uint32_t tile_v_loc; + uint32_t tile_h_size; + uint32_t tile_v_size; +}; + typedef struct _xf86CrtcFuncs { /** * Turns the crtc on/off, or sets intermediate power levels if available. @@ -226,7 +237,7 @@ typedef struct _xf86CrtcFuncs { } xf86CrtcFuncsRec, *xf86CrtcFuncsPtr; -#define XF86_CRTC_VERSION 5 +#define XF86_CRTC_VERSION 6 struct _xf86Crtc { /** @@ -500,7 +511,7 @@ typedef struct _xf86OutputFuncs { (*destroy) (xf86OutputPtr output); } xf86OutputFuncsRec, *xf86OutputFuncsPtr; -#define XF86_OUTPUT_VERSION 2 +#define XF86_OUTPUT_VERSION 3 struct _xf86Output { /** @@ -615,6 +626,8 @@ struct _xf86Output { BoxRec initialTotalArea; BoxRec initialTrackingArea; INT16 initialBorder[4]; + + struct xf86CrtcTileInfo tile_info; }; typedef struct _xf86ProviderFuncs { @@ -881,6 +894,15 @@ extern _X_EXPORT void xf86OutputSetEDID(xf86OutputPtr output, xf86MonPtr edid_mon); /** + * Set the TILE information for the specified output + */ +extern _X_EXPORT void +xf86OutputSetTile(xf86OutputPtr output, struct xf86CrtcTileInfo *tile_info); + +extern _X_EXPORT Bool +xf86OutputParseKMSTile(const char *tile_data, int tile_length, struct xf86CrtcTileInfo *tile_info); + +/** * Return the list of modes supported by the EDID information * stored in 'output' */ diff --git a/xorg-server/hw/xfree86/os-support/linux/systemd-logind.c b/xorg-server/hw/xfree86/os-support/linux/systemd-logind.c index 49758f465..4ad41a374 100644 --- a/xorg-server/hw/xfree86/os-support/linux/systemd-logind.c +++ b/xorg-server/hw/xfree86/os-support/linux/systemd-logind.c @@ -40,8 +40,6 @@ #include "systemd-logind.h" -#define DBUS_TIMEOUT 500 /* Wait max 0.5 seconds */ - struct systemd_logind_info { DBusConnection *conn; char *session; @@ -130,7 +128,7 @@ systemd_logind_take_fd(int _major, int _minor, const char *path, } reply = dbus_connection_send_with_reply_and_block(info->conn, msg, - DBUS_TIMEOUT, &error); + DBUS_TIMEOUT_USE_DEFAULT, &error); if (!reply) { LogMessage(X_ERROR, "systemd-logind: failed to take device %s: %s\n", path, error.message); @@ -207,7 +205,7 @@ systemd_logind_release_fd(int _major, int _minor, int fd) } reply = dbus_connection_send_with_reply_and_block(info->conn, msg, - DBUS_TIMEOUT, &error); + DBUS_TIMEOUT_USE_DEFAULT, &error); if (!reply) LogMessage(X_ERROR, "systemd-logind: failed to release device: %s\n", error.message); @@ -289,7 +287,7 @@ systemd_logind_ack_pause(struct systemd_logind_info *info, } reply = dbus_connection_send_with_reply_and_block(info->conn, msg, - DBUS_TIMEOUT, &error); + DBUS_TIMEOUT_USE_DEFAULT, &error); if (!reply) LogMessage(X_ERROR, "systemd-logind: failed to ack pause: %s\n", error.message); @@ -313,6 +311,9 @@ message_filter(DBusConnection * connection, DBusMessage * message, void *data) dbus_int32_t major, minor; char *pause_str; + if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_SIGNAL) + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + dbus_error_init(&error); if (dbus_message_is_signal(message, @@ -454,7 +455,7 @@ connect_hook(DBusConnection *connection, void *data) } reply = dbus_connection_send_with_reply_and_block(connection, msg, - DBUS_TIMEOUT, &error); + DBUS_TIMEOUT_USE_DEFAULT, &error); if (!reply) { LogMessage(X_ERROR, "systemd-logind: failed to get session: %s\n", error.message); @@ -489,7 +490,7 @@ connect_hook(DBusConnection *connection, void *data) } reply = dbus_connection_send_with_reply_and_block(connection, msg, - DBUS_TIMEOUT, &error); + DBUS_TIMEOUT_USE_DEFAULT, &error); if (!reply) { LogMessage(X_ERROR, "systemd-logind: TakeControl failed: %s\n", error.message); @@ -561,7 +562,7 @@ systemd_logind_release_control(struct systemd_logind_info *info) } reply = dbus_connection_send_with_reply_and_block(info->conn, msg, - DBUS_TIMEOUT, &error); + DBUS_TIMEOUT_USE_DEFAULT, &error); if (!reply) { LogMessage(X_ERROR, "systemd-logind: ReleaseControl failed: %s\n", error.message); diff --git a/xorg-server/hw/xquartz/quartz.c b/xorg-server/hw/xquartz/quartz.c index d7229cecb..851ce4842 100644 --- a/xorg-server/hw/xquartz/quartz.c +++ b/xorg-server/hw/xquartz/quartz.c @@ -43,6 +43,7 @@ #include "darwinEvents.h" #include "pseudoramiX.h" #include "extension.h" +#include "nonsdk_extinit.h" #include "glx_extinit.h" #define _APPLEWM_SERVER_ #include "applewmExt.h" diff --git a/xorg-server/hw/xquartz/xpr/xprScreen.c b/xorg-server/hw/xquartz/xpr/xprScreen.c index d0a525ff4..30f2218b6 100644 --- a/xorg-server/hw/xquartz/xpr/xprScreen.c +++ b/xorg-server/hw/xquartz/xpr/xprScreen.c @@ -54,6 +54,8 @@ #include "damage.h" #endif +#include "nonsdk_extinit.h" + #if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 // From NSApplication.h extern const double NSAppKitVersionNumber; diff --git a/xorg-server/hw/xwayland/Makefile.am b/xorg-server/hw/xwayland/Makefile.am index 994554088..ab1bbb6a5 100644 --- a/xorg-server/hw/xwayland/Makefile.am +++ b/xorg-server/hw/xwayland/Makefile.am @@ -43,6 +43,7 @@ xwayland-glamor.c : $(nodist_Xwayland_SOURCES) glamor_lib = $(top_builddir)/glamor/libglamor.la Xwayland_LDADD += $(GLAMOR_LIBS) $(GBM_LIBS) -lEGL -lGL +Xwayland_DEPENDENCIES = $(glamor_lib) endif EXTRA_DIST = drm.xml diff --git a/xorg-server/hw/xwayland/xwayland-glamor.c b/xorg-server/hw/xwayland/xwayland-glamor.c index dd8551840..d06006c70 100644 --- a/xorg-server/hw/xwayland/xwayland-glamor.c +++ b/xorg-server/hw/xwayland/xwayland-glamor.c @@ -549,11 +549,7 @@ xwl_glamor_init(struct xwl_screen *xwl_screen) return FALSE; } - if (!glamor_init(xwl_screen->screen, - GLAMOR_INVERTED_Y_AXIS | - GLAMOR_USE_EGL_SCREEN | - GLAMOR_USE_SCREEN | - GLAMOR_USE_PICTURE_SCREEN)) { + if (!glamor_init(xwl_screen->screen, GLAMOR_USE_EGL_SCREEN)) { ErrorF("Failed to initialize glamor\n"); return FALSE; } diff --git a/xorg-server/hw/xwin/InitOutput.c b/xorg-server/hw/xwin/InitOutput.c index fe4755c03..5a3d80f7f 100755 --- a/xorg-server/hw/xwin/InitOutput.c +++ b/xorg-server/hw/xwin/InitOutput.c @@ -53,6 +53,11 @@ typedef HRESULT (__stdcall * SHGETFOLDERPATHPROC)(HWND hwndOwner, HANDLE hToken, DWORD dwFlags, LPTSTR pszPath); #endif + +#include "winmonitors.h" +#include "nonsdk_extinit.h" +#include "pseudoramiX/pseudoramiX.h" + #include "glx_extinit.h" #ifdef XWIN_GLX_WINDOWS #include "glx/glwindows.h" @@ -754,13 +759,12 @@ winUseMsg(void) ErrorF("-engine engine_type_id\n" "\tOverride the server's automatically selected engine type:\n" "\t\t1 - Shadow GDI\n" - "\t\t2 - Shadow DirectDraw\n" "\t\t4 - Shadow DirectDraw4 Non-Locking\n" ); ErrorF("-fullscreen\n" "\tRun the server in fullscreen mode.\n"); - ErrorF("-hostintitle\n" + ErrorF("-[no]hostintitle\n" "\tIn multiwindow mode, add remote host names to window titles.\n"); ErrorF("-ignoreinput\n" "\tIgnore keyboard and mouse input.\n"); @@ -987,6 +991,59 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char *argv[]) } } + /* + Unless full xinerama has been explicitly enabled, register all native screens with pseudoramiX + */ + if (!noPanoramiXExtension) + noPseudoramiXExtension = TRUE; + + if ((g_ScreenInfo[0].fMultipleMonitors) && !noPseudoramiXExtension) + { + int pass; + + PseudoramiXExtensionInit(); + + /* Add primary monitor on pass 0, other monitors on pass 1, to ensure + the primary monitor is first in XINERAMA list */ + for (pass = 0; pass < 2; pass++) + { + int iMonitor; + + for (iMonitor = 1; ; iMonitor++) + { + struct GetMonitorInfoData data; + QueryMonitor(iMonitor, &data); + if (data.bMonitorSpecifiedExists) + { + MONITORINFO mi; + mi.cbSize = sizeof(MONITORINFO); + + if (GetMonitorInfo(data.monitorHandle, &mi)) + { + /* pass == 1 XOR primary monitor flags is set */ + if ((!(pass == 1)) != (!(mi.dwFlags & MONITORINFOF_PRIMARY))) + { + /* + Note the screen origin in a normalized coordinate space where (0,0) is at the top left + of the native virtual desktop area + */ + data.monitorOffsetX = data.monitorOffsetX - GetSystemMetrics(SM_XVIRTUALSCREEN); + data.monitorOffsetY = data.monitorOffsetY - GetSystemMetrics(SM_YVIRTUALSCREEN); + + winDebug ("InitOutput - screen %d added at virtual desktop coordinate (%d,%d) (pseudoramiX) \n", + iMonitor-1, data.monitorOffsetX, data.monitorOffsetY); + + PseudoramiXAddScreen(data.monitorOffsetX, data.monitorOffsetY, + data.monitorWidth, data.monitorHeight); + } + } + } + else + break; + } + } + } + #if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW) /* Generate a cookie used by internal clients for authorization */ diff --git a/xorg-server/hw/xwin/Makefile.am b/xorg-server/hw/xwin/Makefile.am index 0ea8ba769..4da3d12a4 100755 --- a/xorg-server/hw/xwin/Makefile.am +++ b/xorg-server/hw/xwin/Makefile.am @@ -71,12 +71,12 @@ SRCS = InitInput.c \ winmsgwindow.c \ winmultiwindowclass.c \ winmultiwindowicons.c \ + winos.c \ winprefs.c \ winprefsyacc.y \ winprefslex.l \ winprocarg.c \ winscrinit.c \ - winshaddd.c \ winshadddnl.c \ winshadgdi.c \ wintaskbar.c \ diff --git a/xorg-server/hw/xwin/XWin.exe.manifest b/xorg-server/hw/xwin/XWin.exe.manifest index 477334fb3..bd44b1066 100644 --- a/xorg-server/hw/xwin/XWin.exe.manifest +++ b/xorg-server/hw/xwin/XWin.exe.manifest @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> - <description>The XWin X Windows server for Cygwin.</description> + <description>The XWin X Windows server</description> <dependency> <dependentAssembly> <assemblyIdentity @@ -18,4 +18,18 @@ <dpiAware>true</dpiAware> </asmv3:windowsSettings> </asmv3:application> + <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> + <application> + <!-- Windows Vista --> + <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> + <!-- Windows 7 --> + <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> + <!-- Windows 8 --> + <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> + <!-- Windows 8.1 --> + <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> + <!-- Windows 10 --> + <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> + </application> + </compatibility> </assembly> diff --git a/xorg-server/hw/xwin/glx/gen_gl_wrappers.py b/xorg-server/hw/xwin/glx/gen_gl_wrappers.py index 840e4366b..a24c5b580 100755 --- a/xorg-server/hw/xwin/glx/gen_gl_wrappers.py +++ b/xorg-server/hw/xwin/glx/gen_gl_wrappers.py @@ -219,6 +219,36 @@ if dispatchheader : del dispatch['glby_offset'] +def ParseCmdRettype(cmd): + proto=noneStr(cmd.elem.find('proto')) + rettype=noneStr(proto.text) + if rettype.lower()!="void ": + plist = ([t for t in proto.itertext()]) + rettype = ''.join(plist[:-1]) + rettype=rettype.strip() + return rettype + +def ParseCmdParams(cmd): + params = cmd.elem.findall('param') + plist=[] + for param in params: + # construct the formal parameter definition from ptype and name + # elements, also using any text found around these in the + # param element, in the order it appears in the document + paramtype = '' + # also extract the formal parameter name from the name element + paramname = '' + for t in param.iter(): + if t.tag == 'ptype' or t.tag == 'param': + paramtype = paramtype + noneStr(t.text) + if t.tag == 'name': + paramname = t.text + '_' + paramtype = paramtype + ' ' + paramname + if t.tail is not None: + paramtype = paramtype + t.tail.strip() + plist.append((paramtype, paramname)) + return plist + class PreResolveOutputGenerator(OutputGenerator): def __init__(self, errFile = sys.stderr, @@ -281,28 +311,15 @@ class MyOutputGenerator(OutputGenerator): return self.wrappers[name]=1 + rettype=ParseCmdRettype(cmd) - proto=noneStr(cmd.elem.find('proto')) - rettype=noneStr(proto.text) - if rettype.lower()!="void ": - plist = ([t for t in proto.itertext()]) - rettype = ''.join(plist[:-1]) - #ptype=proto.find("ptype") - #if ptype!=None: - # rettype = (noneStr(ptype.text))+" " if staticwrappers: self.outFile.write("static ") - self.outFile.write("%s__stdcall %sWrapper("%(rettype, name)) - params = cmd.elem.findall('param') - plist=[] - for param in params: - paramlist = ([t for t in param.itertext()]) - paramtype = ''.join(paramlist[:-1]) - paramname = paramlist[-1] - plist.append((paramtype, paramname)) + self.outFile.write("%s __stdcall %sWrapper("%(rettype, name)) + plist=ParseCmdParams(cmd) Comma="" if len(plist): for ptype, pname in plist: - self.outFile.write("%s%s%s_"%(Comma, ptype, pname)) + self.outFile.write("%s%s"%(Comma, ptype)) Comma=", " else: self.outFile.write("void") @@ -323,7 +340,7 @@ class MyOutputGenerator(OutputGenerator): self.outFile.write(" return %s( "%(name)) Comma="" for ptype, pname in plist: - self.outFile.write("%s%s_"%(Comma, pname)) + self.outFile.write("%s%s"%(Comma, pname)) Comma=", " else: if rettype.lower()=="void ": @@ -348,7 +365,7 @@ class MyOutputGenerator(OutputGenerator): return RESOLVED_PROC(PFN%sPROC)( """%(name.upper())) Comma="" for ptype, pname in plist: - self.outFile.write("%s%s_"%(Comma, pname)) + self.outFile.write("%s%s"%(Comma, pname)) Comma=", " self.outFile.write(" );\n}\n\n") diff --git a/xorg-server/hw/xwin/makefile b/xorg-server/hw/xwin/makefile index 530e02c85..be1088f19 100755 --- a/xorg-server/hw/xwin/makefile +++ b/xorg-server/hw/xwin/makefile @@ -99,12 +99,12 @@ SRCS = InitInput.c \ winmsgwindow.c \ winmultiwindowclass.c \ winmultiwindowicons.c \ + winos.c \ winprefs.c \ winprefsyacc.y \ winprefslex.l \ winprocarg.c \ winscrinit.c \ - winshaddd.c \ winshadddnl.c \ winshadgdi.c \ wintaskbar.c \ diff --git a/xorg-server/hw/xwin/man/XWin.man b/xorg-server/hw/xwin/man/XWin.man index 15a57db02..d68ee2a41 100644 --- a/xorg-server/hw/xwin/man/XWin.man +++ b/xorg-server/hw/xwin/man/XWin.man @@ -76,6 +76,9 @@ preceeding \fB\-screen\fP parameter. .B \-[no]multimonitors or \-[no]multiplemonitors Create a screen 0 that covers all monitors [the primary monitor] on a system with multiple monitors. +Fake XINERAMA data is created describing the individual monitors, +(This is similar to the 'merged framebuffer' or 'pseudo-xinerama' mode provided by +some drivers for the xorg X server). This option is currently enabled by default in \fB\-multiwindow\fP mode. .TP 8 .B "\-screen \fIscreen_number\fP [\fIW\fP \fIH\fP [\fIX\fP \fIY\fP] | [[\fIW\fPx\fIH\fP[+\fIX\fP+\fIY\fP]][@\fIM\fP]] ] " @@ -167,9 +170,10 @@ on its own is equivalent to \fB\-resize=randr\fP .SH OPTIONS FOR MULTIWINDOW MODE .TP 8 -.B \-hostintitle +.B \-[no]hostintitle Add the host name to the window title for X applications which are running on remote hosts, when that information is available and it's useful to do so. +The default is enabled. .SH OPTIONS CONTROLLING WINDOWS INTEGRATION .TP 8 @@ -244,9 +248,6 @@ functionality does not provide a benefit at any number of boxes; we can only determine the usefulness of this feature through testing. This option probably has limited effect on current \fIWindows\fP versions as they already perform GDI batching. -This parameter works in conjunction with engines 1, 2, and 4 (Shadow -GDI, Shadow DirectDraw, and Shadow DirectDraw Non-Locking, -respectively). .TP 8 .B "\-engine \fIengine_type_id\fP" This option, which is intended for Cygwin/X developers, @@ -261,8 +262,6 @@ The engine type ids are: .RS .IP 1 4 Shadow GDI -.IP 2 4 -Shadow DirectDraw .IP 4 4 Shadow DirectDraw Non-Locking .RE diff --git a/xorg-server/hw/xwin/win.h b/xorg-server/hw/xwin/win.h index c4847670e..7b4a8425c 100644..100755 --- a/xorg-server/hw/xwin/win.h +++ b/xorg-server/hw/xwin/win.h @@ -96,7 +96,6 @@ #define WIN_SERVER_NONE 0x0L /* 0 */ #define WIN_SERVER_SHADOW_GDI 0x1L /* 1 */ -#define WIN_SERVER_SHADOW_DD 0x2L /* 2 */ #define WIN_SERVER_SHADOW_DDNL 0x4L /* 4 */ #define AltMapIndex Mod1MapIndex @@ -431,37 +430,20 @@ typedef struct _winPrivScreenRec { int iE3BCachedPress; Bool fE3BFakeButton2Sent; - /* Privates used by shadow fb GDI server */ + /* Privates used by shadow fb GDI engine */ HBITMAP hbmpShadow; HDC hdcScreen; HDC hdcShadow; HWND hwndScreen; BITMAPINFOHEADER *pbmih; - /* Privates used by shadow fb and primary fb DirectDraw servers */ + /* Privates used by shadow fb DirectDraw Nonlocking engine */ LPDIRECTDRAW pdd; - LPDIRECTDRAWSURFACE pddsPrimary; - LPDIRECTDRAW2 pdd2; - - /* Privates used by shadow fb DirectDraw server */ - LPDIRECTDRAWSURFACE pddsShadow; - LPDDSURFACEDESC pddsdShadow; - -#ifdef XWIN_PRIMARYFB - /* Privates used by primary fb DirectDraw server */ - LPDIRECTDRAWSURFACE pddsOffscreen; - LPDDSURFACEDESC pddsdOffscreen; - LPDDSURFACEDESC pddsdPrimary; -#endif - - /* Privates used by shadow fb DirectDraw Nonlocking server */ LPDIRECTDRAW4 pdd4; LPDIRECTDRAWSURFACE4 pddsShadow4; LPDIRECTDRAWSURFACE4 pddsPrimary4; - BOOL fRetryCreateSurface; - - /* Privates used by both shadow fb DirectDraw servers */ LPDIRECTDRAWCLIPPER pddcPrimary; + BOOL fRetryCreateSurface; #ifdef XWIN_MULTIWINDOWEXTWM /* Privates used by multi-window external window manager */ @@ -889,13 +871,6 @@ Bool winFinishScreenInitFB(int i, ScreenPtr pScreen, int argc, char **argv); /* - * winshaddd.c - */ - -Bool - winSetEngineFunctionsShadowDD(ScreenPtr pScreen); - -/* * winshadddnl.c */ @@ -1194,6 +1169,12 @@ Bool winCreateMsgWindowThread(void); /* + * winos.c + */ +void +winOS(void); + +/* * END DDX and DIX Function Prototypes */ diff --git a/xorg-server/hw/xwin/winengine.c b/xorg-server/hw/xwin/winengine.c index dc6ec7e9d..6961930c1 100755 --- a/xorg-server/hw/xwin/winengine.c +++ b/xorg-server/hw/xwin/winengine.c @@ -54,16 +54,9 @@ static HMODULE g_hmodDirectDraw = NULL; void winDetectSupportedEngines(void) { - OSVERSIONINFO osvi; - /* Initialize the engine support flags */ g_dwEnginesSupported = WIN_SERVER_SHADOW_GDI; - /* Get operating system version information */ - ZeroMemory(&osvi, sizeof(osvi)); - osvi.dwOSVersionInfoSize = sizeof(osvi); - GetVersionEx(&osvi); - /* Do we have DirectDraw? */ if (g_hmodDirectDraw != NULL) { LPDIRECTDRAW lpdd = NULL; @@ -85,12 +78,6 @@ winDetectSupportedEngines(void) "winDetectSupportedEngines - DirectDraw not installed\n"); return; } - else { - /* We have DirectDraw */ - winDebug ( - "winDetectSupportedEngines - DirectDraw installed, allowing ShadowDD\n"); - g_dwEnginesSupported |= WIN_SERVER_SHADOW_DD; - } /* Try to query for DirectDraw4 interface */ ddrval = IDirectDraw_QueryInterface(lpdd, @@ -187,9 +174,6 @@ winSetEngine(ScreenPtr pScreen) case WIN_SERVER_SHADOW_GDI: winSetEngineFunctionsShadowGDI(pScreen); break; - case WIN_SERVER_SHADOW_DD: - winSetEngineFunctionsShadowDD(pScreen); - break; case WIN_SERVER_SHADOW_DDNL: winSetEngineFunctionsShadowDDNL(pScreen); break; @@ -209,16 +193,6 @@ winSetEngine(ScreenPtr pScreen) return TRUE; } - /* ShadowDD is next in line */ - if (g_dwEnginesSupported & WIN_SERVER_SHADOW_DD) { - winDebug ("winSetEngine - Using Shadow DirectDraw\n"); - pScreenInfo->dwEngine = WIN_SERVER_SHADOW_DD; - - /* Set engine function pointers */ - winSetEngineFunctionsShadowDD(pScreen); - return TRUE; - } - /* ShadowGDI is next in line */ if (g_dwEnginesSupported & WIN_SERVER_SHADOW_GDI) { winDebug ("winSetEngine - Using Shadow GDI DIB\n"); diff --git a/xorg-server/hw/xwin/winglobals.c b/xorg-server/hw/xwin/winglobals.c index 46202369e..564b0c28c 100755 --- a/xorg-server/hw/xwin/winglobals.c +++ b/xorg-server/hw/xwin/winglobals.c @@ -79,7 +79,7 @@ Bool g_fSoftwareCursor = FALSE; Bool g_fSilentDupError = FALSE; Bool g_fNativeGl = TRUE; Bool g_fswrastwgl = FALSE; -Bool g_fHostInTitle = FALSE; +Bool g_fHostInTitle = TRUE; pthread_mutex_t g_pmTerminating = PTHREAD_MUTEX_INITIALIZER; #ifdef XWIN_CLIPBOARD diff --git a/xorg-server/hw/xwin/winos.c b/xorg-server/hw/xwin/winos.c new file mode 100644 index 000000000..0d825bb83 --- /dev/null +++ b/xorg-server/hw/xwin/winos.c @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2010-2014 Colin Harrison All Rights Reserved. + * + * 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 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 ABOVE LISTED COPYRIGHT HOLDER(S) 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. + * + * Except as contained in this notice, the name(s) of the above copyright + * holders shall not be used in advertising or otherwise to promote the sale, + * use or other dealings in this Software without prior written authorization. + * + * Author: Colin Harrison + */ + +#ifdef HAVE_XWIN_CONFIG_H +#include <xwin-config.h> +#endif +#include "win.h" + +typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS)(HANDLE, PBOOL); + +static const char* +IsWow64(void) +{ +#ifdef __x86_64__ + return " (64-bit)"; +#else + WINBOOL bIsWow64; + LPFN_ISWOW64PROCESS fnIsWow64Process = + (LPFN_ISWOW64PROCESS) GetProcAddress(GetModuleHandle(TEXT("kernel32")), + "IsWow64Process"); + if (NULL != fnIsWow64Process) { + if (fnIsWow64Process(GetCurrentProcess(), &bIsWow64)) + return bIsWow64 ? " (WoW64)" : " (32-bit)"; + } + + /* OS doesn't support IsWow64Process() */ + return ""; +#endif +} + +/* + * Report the OS version + */ + +void +winOS(void) +{ + OSVERSIONINFOEX osvi = {0}; + + /* Get operating system version information */ + osvi.dwOSVersionInfoSize = sizeof(osvi); + GetVersionEx((LPOSVERSIONINFO)&osvi); + + ErrorF("OS: Windows NT %d.%d build %d%s\n", + (int)osvi.dwMajorVersion, (int)osvi.dwMinorVersion, + (int)osvi.dwBuildNumber, IsWow64()); +} diff --git a/xorg-server/hw/xwin/winprocarg.c b/xorg-server/hw/xwin/winprocarg.c index dd328ee80..c2c97324e 100755 --- a/xorg-server/hw/xwin/winprocarg.c +++ b/xorg-server/hw/xwin/winprocarg.c @@ -31,6 +31,10 @@ from The Open Group. #include <xwin-config.h> #endif +#ifdef HAVE_SYS_UTSNAME_H +#include <sys/utsname.h> +#endif + #include <../xfree86/common/xorgVersion.h> #include "win.h" #include "winconfig.h" @@ -1115,6 +1119,11 @@ ddxProcessArgument(int argc, char *argv[], int i) return 1; } + if (IS_OPTION("-nohostintitle")) { + g_fHostInTitle = FALSE; + return 1; + } + return 0; } @@ -1202,6 +1211,17 @@ winLogVersionInfo(void) ErrorF("Vendor: %s\n", XVENDORNAME); ErrorF("Release: %d.%d.%d.%d\n\n", XORG_VERSION_MAJOR, XORG_VERSION_MINOR, XORG_VERSION_PATCH, XORG_VERSION_SNAP); +#ifdef HAVE_SYS_UTSNAME_H + { + struct utsname name; + + if (uname(&name) >= 0) { + ErrorF("OS: %s %s %s %s %s\n", name.sysname, name.nodename, + name.release, name.version, name.machine); + } + } +#endif + winOS(); if (strlen(BUILDERSTRING)) ErrorF("%s\n", BUILDERSTRING); ErrorF("Contact: %s\n", BUILDERADDR); diff --git a/xorg-server/hw/xwin/winscrinit.c b/xorg-server/hw/xwin/winscrinit.c index 9f106f77c..fde6f9427 100755 --- a/xorg-server/hw/xwin/winscrinit.c +++ b/xorg-server/hw/xwin/winscrinit.c @@ -216,15 +216,19 @@ winScreenInit(ScreenPtr pScreen, int argc, char **argv) winDebug("winScreenInit - Using software cursor\n"); #endif - /* - Note the screen origin in a normalized coordinate space where (0,0) is at the top left - of the native virtual desktop area - */ - pScreen->x = pScreenInfo->dwInitialX - GetSystemMetrics(SM_XVIRTUALSCREEN); - pScreen->y = pScreenInfo->dwInitialY - GetSystemMetrics(SM_YVIRTUALSCREEN); + if (!noPanoramiXExtension) { + /* + Note the screen origin in a normalized coordinate space where (0,0) is at the top left + of the native virtual desktop area + */ + pScreen->x = + pScreenInfo->dwInitialX - GetSystemMetrics(SM_XVIRTUALSCREEN); + pScreen->y = + pScreenInfo->dwInitialY - GetSystemMetrics(SM_YVIRTUALSCREEN); - winDebug("Screen %d added at virtual desktop coordinate (%d,%d).\n", - pScreen->myNum, pScreen->x, pScreen->y); + winDebug("Screen %d added at virtual desktop coordinate (%d,%d).\n", + pScreen->myNum, pScreen->x, pScreen->y); + } winDebug("winScreenInit - returning\n"); return TRUE; @@ -306,8 +310,6 @@ winFinishScreenInitFB(int i, ScreenPtr pScreen, int argc, char **argv) if (pScreenInfo->dwDepth == 8 && (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI || (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL - && pScreenInfo->fFullScreen) - || (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD && pScreenInfo->fFullScreen))) { winSetColormapFunctions(pScreen); @@ -377,7 +379,6 @@ winFinishScreenInitFB(int i, ScreenPtr pScreen, int argc, char **argv) /* Initialize the shadow framebuffer layer */ if ((pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI - || pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD || pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL) #ifdef XWIN_MULTIWINDOWEXTWM && !pScreenInfo->fMWExtWM diff --git a/xorg-server/hw/xwin/winshaddd.c b/xorg-server/hw/xwin/winshaddd.c deleted file mode 100644 index 688cc58d2..000000000 --- a/xorg-server/hw/xwin/winshaddd.c +++ /dev/null @@ -1,1198 +0,0 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - * - *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 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 XFREE86 PROJECT 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. - * - *Except as contained in this notice, the name of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Dakshinamurthy Karra - * Suhaib M Siddiqi - * Peter Busch - * Harold L Hunt II - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" -#include "winprefs.h" - -/* - * Local prototypes - */ - -static Bool - winAllocateFBShadowDD(ScreenPtr pScreen); - -static void - winShadowUpdateDD(ScreenPtr pScreen, shadowBufPtr pBuf); - -static Bool - winCloseScreenShadowDD(ScreenPtr pScreen); - -static Bool - winInitVisualsShadowDD(ScreenPtr pScreen); - -static Bool - winAdjustVideoModeShadowDD(ScreenPtr pScreen); - -static Bool - winBltExposedRegionsShadowDD(ScreenPtr pScreen); - -static Bool - winActivateAppShadowDD(ScreenPtr pScreen); - -static Bool - winRedrawScreenShadowDD(ScreenPtr pScreen); - -static Bool - winRealizeInstalledPaletteShadowDD(ScreenPtr pScreen); - -static Bool - winInstallColormapShadowDD(ColormapPtr pColormap); - -static Bool - winStoreColorsShadowDD(ColormapPtr pmap, int ndef, xColorItem * pdefs); - -static Bool - winCreateColormapShadowDD(ColormapPtr pColormap); - -static Bool - winDestroyColormapShadowDD(ColormapPtr pColormap); - -static Bool - winCreatePrimarySurfaceShadowDD(ScreenPtr pScreen); - -static Bool - winReleasePrimarySurfaceShadowDD(ScreenPtr pScreen); - -/* - * Create the primary surface and attach the clipper. - * Used for both the initial surface creation and during - * WM_DISPLAYCHANGE messages. - */ - -static Bool -winCreatePrimarySurfaceShadowDD(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - HRESULT ddrval = DD_OK; - DDSURFACEDESC ddsd; - - /* Describe the primary surface */ - ZeroMemory(&ddsd, sizeof(ddsd)); - ddsd.dwSize = sizeof(ddsd); - ddsd.dwFlags = DDSD_CAPS; - ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; - - /* Create the primary surface */ - ddrval = IDirectDraw2_CreateSurface(pScreenPriv->pdd2, - &ddsd, &pScreenPriv->pddsPrimary, NULL); - if (FAILED(ddrval)) { - ErrorF("winCreatePrimarySurfaceShadowDD - Could not create primary " - "surface: %08x\n", (unsigned int) ddrval); - return FALSE; - } - - winDebug("winCreatePrimarySurfaceShadowDD - Created primary surface\n"); - - /* - * Attach a clipper to the primary surface that will clip our blits to our - * display window. - */ - ddrval = IDirectDrawSurface2_SetClipper(pScreenPriv->pddsPrimary, - pScreenPriv->pddcPrimary); - if (FAILED(ddrval)) { - ErrorF("winCreatePrimarySurfaceShadowDD - Primary attach clipper " - "failed: %08x\n", (unsigned int) ddrval); - return FALSE; - } - - winDebug("winCreatePrimarySurfaceShadowDD - Attached clipper to " - "primary surface\n"); - - /* Everything was correct */ - return TRUE; -} - -/* - * Detach the clipper and release the primary surface. - * Called from WM_DISPLAYCHANGE. - */ - -static Bool -winReleasePrimarySurfaceShadowDD(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - - winDebug ("winReleasePrimarySurfaceShadowDD - Hello\n"); - - /* Release the primary surface and clipper, if they exist */ - if (pScreenPriv->pddsPrimary) { - /* - * Detach the clipper from the primary surface. - * NOTE: We do this explicity for clarity. The Clipper is not released. - */ - IDirectDrawSurface2_SetClipper(pScreenPriv->pddsPrimary, NULL); - - winDebug ("winReleasePrimarySurfaceShadowDD - Detached clipper\n"); - - /* Release the primary surface */ - IDirectDrawSurface2_Release(pScreenPriv->pddsPrimary); - pScreenPriv->pddsPrimary = NULL; - } - - winDebug ("winReleasePrimarySurfaceShadowDD - Released primary surface\n"); - - return TRUE; -} - -/* - * Create a DirectDraw surface for the shadow framebuffer; also create - * a primary surface object so we can blit to the display. - * - * Install a DirectDraw clipper on our primary surface object - * that clips our blits to the unobscured client area of our display window. - */ - -static Bool -winAllocateFBShadowDD(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - HRESULT ddrval = DD_OK; - DDSURFACEDESC ddsd; - DDSURFACEDESC *pddsdShadow = NULL; - - winDebug("winAllocateFBShadowDD\n"); - - /* Create a clipper */ - ddrval = (*g_fpDirectDrawCreateClipper) (0, - &pScreenPriv->pddcPrimary, NULL); - if (FAILED(ddrval)) { - ErrorF("winAllocateFBShadowDD - Could not create clipper: %08x\n", - (unsigned int) ddrval); - return FALSE; - } - - winDebug("winAllocateFBShadowDD - Created a clipper\n"); - - /* Attach the clipper to our display window */ - ddrval = IDirectDrawClipper_SetHWnd(pScreenPriv->pddcPrimary, - 0, pScreenPriv->hwndScreen); - if (FAILED(ddrval)) { - ErrorF("winAllocateFBShadowDD - Clipper not attached to " - "window: %08x\n", (unsigned int) ddrval); - return FALSE; - } - - winDebug("winAllocateFBShadowDD - Attached clipper to window\n"); - - /* Create a DirectDraw object, store the address at lpdd */ - ddrval = (*g_fpDirectDrawCreate) (NULL, &pScreenPriv->pdd, NULL); - if (FAILED(ddrval)) { - ErrorF("winAllocateFBShadowDD - Could not start DirectDraw: %08x\n", - (unsigned int) ddrval); - return FALSE; - } - - winDebug("winAllocateFBShadowDD () - Created and initialized DD\n"); - - /* Get a DirectDraw2 interface pointer */ - ddrval = IDirectDraw_QueryInterface(pScreenPriv->pdd, - &IID_IDirectDraw2, - (LPVOID *) &pScreenPriv->pdd2); - if (FAILED(ddrval)) { - ErrorF("winAllocateFBShadowDD - Failed DD2 query: %08x\n", - (unsigned int) ddrval); - return FALSE; - } - - /* Are we full screen? */ - if (pScreenInfo->fFullScreen) { - DDSURFACEDESC ddsdCurrent; - DWORD dwRefreshRateCurrent = 0; - HDC hdc = NULL; - - /* Set the cooperative level to full screen */ - ddrval = IDirectDraw2_SetCooperativeLevel(pScreenPriv->pdd2, - pScreenPriv->hwndScreen, - DDSCL_EXCLUSIVE - | DDSCL_FULLSCREEN); - if (FAILED(ddrval)) { - ErrorF("winAllocateFBShadowDD - Could not set " - "cooperative level: %08x\n", (unsigned int) ddrval); - return FALSE; - } - - /* - * We only need to get the current refresh rate for comparison - * if a refresh rate has been passed on the command line. - */ - if (pScreenInfo->dwRefreshRate != 0) { - ZeroMemory(&ddsdCurrent, sizeof(ddsdCurrent)); - ddsdCurrent.dwSize = sizeof(ddsdCurrent); - - /* Get information about current display settings */ - ddrval = IDirectDraw2_GetDisplayMode(pScreenPriv->pdd2, - &ddsdCurrent); - if (FAILED(ddrval)) { - ErrorF("winAllocateFBShadowDD - Could not get current " - "refresh rate: %08x. Continuing.\n", - (unsigned int) ddrval); - dwRefreshRateCurrent = 0; - } - else { - /* Grab the current refresh rate */ - dwRefreshRateCurrent = ddsdCurrent.u2.dwRefreshRate; - } - } - - /* Clean up the refresh rate */ - if (dwRefreshRateCurrent == pScreenInfo->dwRefreshRate) { - /* - * Refresh rate is non-specified or equal to current. - */ - pScreenInfo->dwRefreshRate = 0; - } - - /* Grab a device context for the screen */ - hdc = GetDC(NULL); - if (hdc == NULL) { - ErrorF("winAllocateFBShadowDD - GetDC () failed\n"); - return FALSE; - } - - /* Only change the video mode when different than current mode */ - if (!pScreenInfo->fMultipleMonitors - && (pScreenInfo->dwWidth != GetSystemMetrics(SM_CXSCREEN) - || pScreenInfo->dwHeight != GetSystemMetrics(SM_CYSCREEN) - || pScreenInfo->dwBPP != GetDeviceCaps(hdc, BITSPIXEL) - || pScreenInfo->dwRefreshRate != 0)) { - winDebug ("winAllocateFBShadowDD - Changing video mode\n"); - - /* Change the video mode to the mode requested, and use the driver default refresh rate on failure */ - ddrval = IDirectDraw2_SetDisplayMode(pScreenPriv->pdd2, - pScreenInfo->dwWidth, - pScreenInfo->dwHeight, - pScreenInfo->dwBPP, - pScreenInfo->dwRefreshRate, 0); - if (FAILED(ddrval)) { - ErrorF("winAllocateFBShadowDD - Could not set " - "full screen display mode: %08x\n", - (unsigned int) ddrval); - ErrorF - ("winAllocateFBShadowDD - Using default driver refresh rate\n"); - ddrval = - IDirectDraw2_SetDisplayMode(pScreenPriv->pdd2, - pScreenInfo->dwWidth, - pScreenInfo->dwHeight, - pScreenInfo->dwBPP, 0, 0); - if (FAILED(ddrval)) { - ErrorF - ("winAllocateFBShadowDD - Could not set default refresh rate " - "full screen display mode: %08x\n", - (unsigned int) ddrval); - return FALSE; - } - } - } - else { - winDebug ("winAllocateFBShadowDD - Not changing video mode\n"); - } - - /* Release our DC */ - ReleaseDC(NULL, hdc); - hdc = NULL; - } - else { - /* Set the cooperative level for windowed mode */ - ddrval = IDirectDraw2_SetCooperativeLevel(pScreenPriv->pdd2, - pScreenPriv->hwndScreen, - DDSCL_NORMAL); - if (FAILED(ddrval)) { - ErrorF("winAllocateFBShadowDD - Could not set " - "cooperative level: %08x\n", (unsigned int) ddrval); - return FALSE; - } - } - - /* Create the primary surface */ - if (!winCreatePrimarySurfaceShadowDD(pScreen)) { - ErrorF("winAllocateFBShadowDD - winCreatePrimarySurfaceShadowDD " - "failed\n"); - return FALSE; - } - - /* Describe the shadow surface to be created */ - /* NOTE: Do not use a DDSCAPS_VIDEOMEMORY surface, - * as drawing, locking, and unlocking take forever - * with video memory surfaces. In addition, - * video memory is a somewhat scarce resource, - * so you shouldn't be allocating video memory when - * you have the option of using system memory instead. - */ - ZeroMemory(&ddsd, sizeof(ddsd)); - ddsd.dwSize = sizeof(ddsd); - ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; - ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; - ddsd.dwHeight = pScreenInfo->dwHeight; - ddsd.dwWidth = pScreenInfo->dwWidth; - - /* Create the shadow surface */ - ddrval = IDirectDraw2_CreateSurface(pScreenPriv->pdd2, - &ddsd, &pScreenPriv->pddsShadow, NULL); - if (FAILED(ddrval)) { - ErrorF("winAllocateFBShadowDD - Could not create shadow " - "surface: %08x\n", (unsigned int) ddrval); - return FALSE; - } - - winDebug("winAllocateFBShadowDD - Created shadow\n"); - - /* Allocate a DD surface description for our screen privates */ - pddsdShadow = pScreenPriv->pddsdShadow = malloc(sizeof(DDSURFACEDESC)); - if (pddsdShadow == NULL) { - ErrorF("winAllocateFBShadowDD - Could not allocate surface " - "description memory\n"); - return FALSE; - } - ZeroMemory(pddsdShadow, sizeof(*pddsdShadow)); - pddsdShadow->dwSize = sizeof(*pddsdShadow); - - winDebug("winAllocateFBShadowDD - Locking shadow\n"); - - /* Lock the shadow surface */ - ddrval = IDirectDrawSurface2_Lock(pScreenPriv->pddsShadow, - NULL, pddsdShadow, DDLOCK_WAIT, NULL); - if (FAILED(ddrval) || pddsdShadow->lpSurface == NULL) { - ErrorF("winAllocateFBShadowDD - Could not lock shadow " - "surface: %08x\n", (unsigned int) ddrval); - return FALSE; - } - - winDebug("winAllocateFBShadowDD - Locked shadow\n"); - - /* We don't know how to deal with anything other than RGB */ - if (!(pddsdShadow->ddpfPixelFormat.dwFlags & DDPF_RGB)) { - ErrorF("winAllocateFBShadowDD - Color format other than RGB\n"); - return FALSE; - } - - /* Grab the pitch from the surface desc */ - pScreenInfo->dwStride = (pddsdShadow->u1.lPitch * 8) - / pScreenInfo->dwBPP; - - /* Save the pointer to our surface memory */ - pScreenInfo->pfb = pddsdShadow->lpSurface; - - /* Grab the color depth and masks from the surface description */ - pScreenPriv->dwRedMask = pddsdShadow->ddpfPixelFormat.u2.dwRBitMask; - pScreenPriv->dwGreenMask = pddsdShadow->ddpfPixelFormat.u3.dwGBitMask; - pScreenPriv->dwBlueMask = pddsdShadow->ddpfPixelFormat.u4.dwBBitMask; - - winDebug("winAllocateFBShadowDD - Returning\n"); - - return TRUE; -} - -static void -winFreeFBShadowDD(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - - /* Free the shadow surface, if there is one */ - if (pScreenPriv->pddsShadow) { - IDirectDrawSurface2_Unlock(pScreenPriv->pddsShadow, NULL); - IDirectDrawSurface2_Release(pScreenPriv->pddsShadow); - pScreenPriv->pddsShadow = NULL; - } - - /* Detach the clipper from the primary surface and release the primary surface, if there is one */ - winReleasePrimarySurfaceShadowDD(pScreen); - - /* Release the clipper object */ - if (pScreenPriv->pddcPrimary) { - IDirectDrawClipper_Release(pScreenPriv->pddcPrimary); - pScreenPriv->pddcPrimary = NULL; - } - - /* Free the DirectDraw2 object, if there is one */ - if (pScreenPriv->pdd2) { - IDirectDraw2_RestoreDisplayMode(pScreenPriv->pdd2); - IDirectDraw2_Release(pScreenPriv->pdd2); - pScreenPriv->pdd2 = NULL; - } - - /* Free the DirectDraw object, if there is one */ - if (pScreenPriv->pdd) { - IDirectDraw_Release(pScreenPriv->pdd); - pScreenPriv->pdd = NULL; - } - - /* Invalidate the ScreenInfo's fb pointer */ - pScreenInfo->pfb = NULL; -} - -/* - * Transfer the damaged regions of the shadow framebuffer to the display. - */ - -static void -winShadowUpdateDD(ScreenPtr pScreen, shadowBufPtr pBuf) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - RegionPtr damage = shadowDamage(pBuf); - HRESULT ddrval = DD_OK; - RECT rcDest, rcSrc; - POINT ptOrigin; - DWORD dwBox = RegionNumRects(damage); - BoxPtr pBox = RegionRects(damage); - HRGN hrgnCombined = NULL; - - /* - * Return immediately if the app is not active - * and we are fullscreen, or if we have a bad display depth - */ - if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen) - || pScreenPriv->fBadDepth) - return; - - /* Return immediately if we didn't get needed surfaces */ - if (!pScreenPriv->pddsPrimary || !pScreenPriv->pddsShadow) - return; - - /* Get the origin of the window in the screen coords */ - ptOrigin.x = pScreenInfo->dwXOffset; - ptOrigin.y = pScreenInfo->dwYOffset; - MapWindowPoints(pScreenPriv->hwndScreen, - HWND_DESKTOP, (LPPOINT) &ptOrigin, 1); - - /* Unlock the shadow surface, so we can blit */ - ddrval = IDirectDrawSurface2_Unlock(pScreenPriv->pddsShadow, NULL); - if (FAILED(ddrval)) { - ErrorF("winShadowUpdateDD - Unlock failed\n"); - return; - } - - /* - * Handle small regions with multiple blits, - * handle large regions by creating a clipping region and - * doing a single blit constrained to that clipping region. - */ - if (pScreenInfo->dwClipUpdatesNBoxes == 0 - || dwBox < pScreenInfo->dwClipUpdatesNBoxes) { - /* Loop through all boxes in the damaged region */ - while (dwBox--) { - /* Assign damage box to source rectangle */ - rcSrc.left = pBox->x1; - rcSrc.top = pBox->y1; - rcSrc.right = pBox->x2; - rcSrc.bottom = pBox->y2; - - /* Calculate destination rectange */ - rcDest.left = ptOrigin.x + rcSrc.left; - rcDest.top = ptOrigin.y + rcSrc.top; - rcDest.right = ptOrigin.x + rcSrc.right; - rcDest.bottom = ptOrigin.y + rcSrc.bottom; - - /* Blit the damaged areas */ - ddrval = IDirectDrawSurface2_Blt(pScreenPriv->pddsPrimary, - &rcDest, - pScreenPriv->pddsShadow, - &rcSrc, DDBLT_WAIT, NULL); - - /* Get a pointer to the next box */ - ++pBox; - } - } - else { - BoxPtr pBoxExtents = RegionExtents(damage); - - /* Compute a GDI region from the damaged region */ - hrgnCombined = - CreateRectRgn(pBoxExtents->x1, pBoxExtents->y1, pBoxExtents->x2, - pBoxExtents->y2); - - /* Install the GDI region as a clipping region */ - SelectClipRgn(pScreenPriv->hdcScreen, hrgnCombined); - DeleteObject(hrgnCombined); - hrgnCombined = NULL; - - /* Calculating a bounding box for the source is easy */ - rcSrc.left = pBoxExtents->x1; - rcSrc.top = pBoxExtents->y1; - rcSrc.right = pBoxExtents->x2; - rcSrc.bottom = pBoxExtents->y2; - - /* Calculating a bounding box for the destination is trickier */ - rcDest.left = ptOrigin.x + rcSrc.left; - rcDest.top = ptOrigin.y + rcSrc.top; - rcDest.right = ptOrigin.x + rcSrc.right; - rcDest.bottom = ptOrigin.y + rcSrc.bottom; - - /* Our Blt should be clipped to the invalidated region */ - ddrval = IDirectDrawSurface2_Blt(pScreenPriv->pddsPrimary, - &rcDest, - pScreenPriv->pddsShadow, - &rcSrc, DDBLT_WAIT, NULL); - - /* Reset the clip region */ - SelectClipRgn(pScreenPriv->hdcScreen, NULL); - } - - /* Relock the shadow surface */ - ddrval = IDirectDrawSurface2_Lock(pScreenPriv->pddsShadow, - NULL, - pScreenPriv->pddsdShadow, - DDLOCK_WAIT, NULL); - if (FAILED(ddrval)) { - ErrorF("winShadowUpdateDD - Lock failed\n"); - return; - } - - /* Has our memory pointer changed? */ - if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface) { - extern const char *g_pszLogFile; - ErrorF("winShadowUpdateDD - Memory location of the shadow " - "surface has changed, trying to update the root window " - "pixmap header to point to the new address. If you get " - "this message and " PROJECT_NAME " freezes or crashes " - "after this message then send a problem report and your " - "%s file to " BUILDERADDR "\n", g_pszLogFile); - - /* Location of shadow framebuffer has changed */ - winUpdateFBPointer(pScreen, pScreenPriv->pddsdShadow->lpSurface); - } -} - -static Bool -winInitScreenShadowDD(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - - /* Get a device context for the screen */ - pScreenPriv->hdcScreen = GetDC(pScreenPriv->hwndScreen); - - return winAllocateFBShadowDD(pScreen); -} - -/* - * Call the wrapped CloseScreen function. - * - * Free our resources and private structures. - */ - -static Bool -winCloseScreenShadowDD(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - Bool fReturn; - - winDebug("winCloseScreenShadowDD - Freeing screen resources\n"); - - /* Flag that the screen is closed */ - pScreenPriv->fClosed = TRUE; - pScreenPriv->fActive = FALSE; - - /* Call the wrapped CloseScreen procedure */ - WIN_UNWRAP(CloseScreen); - if (pScreen->CloseScreen) - fReturn = (*pScreen->CloseScreen) (pScreen); - - winFreeFBShadowDD(pScreen); - - /* Free the screen DC */ - ReleaseDC(pScreenPriv->hwndScreen, pScreenPriv->hdcScreen); - - /* Delete the window property */ - RemoveProp(pScreenPriv->hwndScreen, WIN_SCR_PROP); - - /* Delete tray icon, if we have one */ - if (!pScreenInfo->fNoTrayIcon && !pref.fNoTrayIcon) - winDeleteNotifyIcon(pScreenPriv); - - /* Free the exit confirmation dialog box, if it exists */ - if (g_hDlgExit != NULL) { - DestroyWindow(g_hDlgExit); - g_hDlgExit = NULL; - } - - /* Kill our window */ - if (pScreenPriv->hwndScreen) { - DestroyWindow(pScreenPriv->hwndScreen); - pScreenPriv->hwndScreen = NULL; - } - -#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW) - /* Destroy the thread startup mutex */ - if (pScreenPriv->pmServerStarted) pthread_mutex_destroy (&pScreenPriv->pmServerStarted); -#endif - - /* Kill our screeninfo's pointer to the screen */ - pScreenInfo->pScreen = NULL; - - /* Free the screen privates for this screen */ - free((void *) pScreenPriv); - - return fReturn; -} - -/* - * Tell mi what sort of visuals we need. - * - * Generally we only need one visual, as our screen can only - * handle one format at a time, I believe. You may want - * to verify that last sentence. - */ - -static Bool -winInitVisualsShadowDD(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - DWORD dwRedBits, dwGreenBits, dwBlueBits; - - /* Count the number of ones in each color mask */ - dwRedBits = winCountBits(pScreenPriv->dwRedMask); - dwGreenBits = winCountBits(pScreenPriv->dwGreenMask); - dwBlueBits = winCountBits(pScreenPriv->dwBlueMask); - - /* Store the maximum number of ones in a color mask as the bitsPerRGB */ - if (dwRedBits == 0 || dwGreenBits == 0 || dwBlueBits == 0) - pScreenPriv->dwBitsPerRGB = 8; - else if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits) - pScreenPriv->dwBitsPerRGB = dwRedBits; - else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits) - pScreenPriv->dwBitsPerRGB = dwGreenBits; - else - pScreenPriv->dwBitsPerRGB = dwBlueBits; - - winDebug ("winInitVisualsShadowDD - Masks %08x %08x %08x BPRGB %d d %d " - "bpp %d\n", - (unsigned int) pScreenPriv->dwRedMask, - (unsigned int) pScreenPriv->dwGreenMask, - (unsigned int) pScreenPriv->dwBlueMask, - (int) pScreenPriv->dwBitsPerRGB, - (int) pScreenInfo->dwDepth, (int) pScreenInfo->dwBPP); - - /* Create a single visual according to the Windows screen depth */ - switch (pScreenInfo->dwDepth) { - case 24: - case 16: - case 15: - /* Create the real visual */ - if (!miSetVisualTypesAndMasks(pScreenInfo->dwDepth, - TrueColorMask, - pScreenPriv->dwBitsPerRGB, - TrueColor, - pScreenPriv->dwRedMask, - pScreenPriv->dwGreenMask, - pScreenPriv->dwBlueMask)) { - ErrorF("winInitVisualsShadowDD - miSetVisualTypesAndMasks " - "failed for TrueColor\n"); - return FALSE; - } - -#ifdef XWIN_EMULATEPSEUDO - if (!pScreenInfo->fEmulatePseudo) - break; - - /* Setup a pseudocolor visual */ - if (!miSetVisualTypesAndMasks(8, PseudoColorMask, 8, -1, 0, 0, 0)) { - ErrorF("winInitVisualsShadowDD - miSetVisualTypesAndMasks " - "failed for PseudoColor\n"); - return FALSE; - } -#endif - break; - - case 8: - if (!miSetVisualTypesAndMasks(pScreenInfo->dwDepth, - pScreenInfo->fFullScreen - ? PseudoColorMask : StaticColorMask, - pScreenPriv->dwBitsPerRGB, - pScreenInfo->fFullScreen - ? PseudoColor : StaticColor, - pScreenPriv->dwRedMask, - pScreenPriv->dwGreenMask, - pScreenPriv->dwBlueMask)) { - ErrorF("winInitVisualsShadowDD - miSetVisualTypesAndMasks " - "failed\n"); - return FALSE; - } - break; - - default: - ErrorF("winInitVisualsShadowDD - Unknown screen depth\n"); - return FALSE; - } - - winDebug("winInitVisualsShadowDD - Returning\n"); - - return TRUE; -} - -/* - * Adjust the user proposed video mode - */ - -static Bool -winAdjustVideoModeShadowDD(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - HDC hdc = NULL; - DWORD dwBPP; - - /* We're in serious trouble if we can't get a DC */ - hdc = GetDC(NULL); - if (hdc == NULL) { - ErrorF("winAdjustVideoModeShadowDD - GetDC () failed\n"); - return FALSE; - } - - /* Query GDI for current display depth */ - dwBPP = GetDeviceCaps(hdc, BITSPIXEL); - - /* DirectDraw can only change the depth in fullscreen mode */ - if (!(pScreenInfo->fFullScreen && (pScreenInfo->dwBPP != WIN_DEFAULT_BPP))) { - /* Otherwise, We'll use GDI's depth */ - pScreenInfo->dwBPP = dwBPP; - } - - /* Release our DC */ - ReleaseDC(NULL, hdc); - return TRUE; -} - -/* - * Blt exposed regions to the screen - */ - -static Bool -winBltExposedRegionsShadowDD(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - RECT rcSrc, rcDest; - POINT ptOrigin; - HDC hdcUpdate = NULL; - PAINTSTRUCT ps; - HRESULT ddrval = DD_OK; - Bool fReturn = TRUE; - Bool fLocked = TRUE; - int i; - - /* BeginPaint gives us an hdc that clips to the invalidated region */ - hdcUpdate = BeginPaint(pScreenPriv->hwndScreen, &ps); - if (hdcUpdate == NULL) { - ErrorF("winBltExposedRegionsShadowDD - BeginPaint () returned " - "a NULL device context handle. Aborting blit attempt.\n"); - return FALSE; - } - - /* Unlock the shadow surface, so we can blit */ - ddrval = IDirectDrawSurface2_Unlock(pScreenPriv->pddsShadow, NULL); - if (FAILED(ddrval)) { - fReturn = FALSE; - goto winBltExposedRegionsShadowDD_Exit; - } - else { - /* Flag that we have unlocked the shadow surface */ - fLocked = FALSE; - } - - /* Get the origin of the window in the screen coords */ - ptOrigin.x = pScreenInfo->dwXOffset; - ptOrigin.y = pScreenInfo->dwYOffset; - - MapWindowPoints(pScreenPriv->hwndScreen, - HWND_DESKTOP, (LPPOINT) &ptOrigin, 1); - rcDest.left = ptOrigin.x; - rcDest.right = ptOrigin.x + pScreenInfo->dwWidth; - rcDest.top = ptOrigin.y; - rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight; - - /* Source can be enter shadow surface, as Blt should clip */ - rcSrc.left = 0; - rcSrc.top = 0; - rcSrc.right = pScreenInfo->dwWidth; - rcSrc.bottom = pScreenInfo->dwHeight; - - /* Try to regain the primary surface and blit again if we've lost it */ - for (i = 0; i <= WIN_REGAIN_SURFACE_RETRIES; ++i) { - /* Our Blt should be clipped to the invalidated region */ - ddrval = IDirectDrawSurface2_Blt(pScreenPriv->pddsPrimary, - &rcDest, - pScreenPriv->pddsShadow, - &rcSrc, DDBLT_WAIT, NULL); - if (ddrval == DDERR_SURFACELOST) { - /* Surface was lost */ - ErrorF("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Blt " - "reported that the primary surface was lost, " - "trying to restore, retry: %d\n", i + 1); - - /* Try to restore the surface, once */ - ddrval = IDirectDrawSurface2_Restore(pScreenPriv->pddsPrimary); - ErrorF("winBltExposedRegionsShadowDD - " - "IDirectDrawSurface2_Restore returned: "); - if (ddrval == DD_OK) - ErrorF("DD_OK\n"); - else if (ddrval == DDERR_WRONGMODE) - ErrorF("DDERR_WRONGMODE\n"); - else if (ddrval == DDERR_INCOMPATIBLEPRIMARY) - ErrorF("DDERR_INCOMPATIBLEPRIMARY\n"); - else if (ddrval == DDERR_UNSUPPORTED) - ErrorF("DDERR_UNSUPPORTED\n"); - else if (ddrval == DDERR_INVALIDPARAMS) - ErrorF("DDERR_INVALIDPARAMS\n"); - else if (ddrval == DDERR_INVALIDOBJECT) - ErrorF("DDERR_INVALIDOBJECT\n"); - else - ErrorF("unknown error: %08x\n", (unsigned int) ddrval); - - /* Loop around to try the blit one more time */ - continue; - } - else if (FAILED(ddrval)) { - fReturn = FALSE; - ErrorF("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Blt " - "failed, but surface not lost: %08x %d\n", - (unsigned int) ddrval, (int) ddrval); - goto winBltExposedRegionsShadowDD_Exit; - } - else { - /* Success, stop looping */ - break; - } - } - - /* Relock the shadow surface */ - ddrval = IDirectDrawSurface2_Lock(pScreenPriv->pddsShadow, - NULL, - pScreenPriv->pddsdShadow, - DDLOCK_WAIT, NULL); - if (FAILED(ddrval)) { - fReturn = FALSE; - ErrorF("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Lock " - "failed\n"); - goto winBltExposedRegionsShadowDD_Exit; - } - else { - /* Indicate that we have relocked the shadow surface */ - fLocked = TRUE; - } - - /* Has our memory pointer changed? */ - if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface) - winUpdateFBPointer(pScreen, pScreenPriv->pddsdShadow->lpSurface); - - winBltExposedRegionsShadowDD_Exit: - /* EndPaint frees the DC */ - if (hdcUpdate != NULL) - EndPaint(pScreenPriv->hwndScreen, &ps); - - /* - * Relock the surface if it is not locked. We don't care if locking fails, - * as it will cause the server to shutdown within a few more operations. - */ - if (!fLocked) { - IDirectDrawSurface2_Lock(pScreenPriv->pddsShadow, - NULL, - pScreenPriv->pddsdShadow, DDLOCK_WAIT, NULL); - - /* Has our memory pointer changed? */ - if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface) - winUpdateFBPointer(pScreen, pScreenPriv->pddsdShadow->lpSurface); - - fLocked = TRUE; - } - return fReturn; -} - -/* - * Do any engine-specific appliation-activation processing - */ - -static Bool -winActivateAppShadowDD(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - - /* - * Do we have a surface? - * Are we active? - * Are we fullscreen? - */ - if (pScreenPriv != NULL - && pScreenPriv->pddsPrimary != NULL && pScreenPriv->fActive) { - /* Primary surface was lost, restore it */ - IDirectDrawSurface2_Restore(pScreenPriv->pddsPrimary); - } - - return TRUE; -} - -/* - * Reblit the shadow framebuffer to the screen. - */ - -static Bool -winRedrawScreenShadowDD(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - HRESULT ddrval = DD_OK; - RECT rcSrc, rcDest; - POINT ptOrigin; - - /* Get the origin of the window in the screen coords */ - ptOrigin.x = pScreenInfo->dwXOffset; - ptOrigin.y = pScreenInfo->dwYOffset; - MapWindowPoints(pScreenPriv->hwndScreen, - HWND_DESKTOP, (LPPOINT) &ptOrigin, 1); - rcDest.left = ptOrigin.x; - rcDest.right = ptOrigin.x + pScreenInfo->dwWidth; - rcDest.top = ptOrigin.y; - rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight; - - /* Source can be entire shadow surface, as Blt should clip for us */ - rcSrc.left = 0; - rcSrc.top = 0; - rcSrc.right = pScreenInfo->dwWidth; - rcSrc.bottom = pScreenInfo->dwHeight; - - /* Redraw the whole window, to take account for the new colors */ - ddrval = IDirectDrawSurface2_Blt(pScreenPriv->pddsPrimary, - &rcDest, - pScreenPriv->pddsShadow, - &rcSrc, DDBLT_WAIT, NULL); - if (FAILED(ddrval)) { - ErrorF("winRedrawScreenShadowDD - IDirectDrawSurface_Blt () " - "failed: %08x\n", (unsigned int) ddrval); - return FALSE; - } - - return TRUE; -} - -/* - * Realize the currently installed colormap - */ - -static Bool -winRealizeInstalledPaletteShadowDD(ScreenPtr pScreen) -{ - return TRUE; -} - -/* - * Install the specified colormap - */ - -static Bool -winInstallColormapShadowDD(ColormapPtr pColormap) -{ - ScreenPtr pScreen = pColormap->pScreen; - - winScreenPriv(pScreen); - winCmapPriv(pColormap); - HRESULT ddrval = DD_OK; - - /* Install the DirectDraw palette on the primary surface */ - ddrval = IDirectDrawSurface2_SetPalette(pScreenPriv->pddsPrimary, - pCmapPriv->lpDDPalette); - if (FAILED(ddrval)) { - ErrorF("winInstallColormapShadowDD - Failed installing the " - "DirectDraw palette.\n"); - return FALSE; - } - - /* Save a pointer to the newly installed colormap */ - pScreenPriv->pcmapInstalled = pColormap; - - return TRUE; -} - -/* - * Store the specified colors in the specified colormap - */ - -static Bool -winStoreColorsShadowDD(ColormapPtr pColormap, int ndef, xColorItem * pdefs) -{ - ScreenPtr pScreen = pColormap->pScreen; - - winScreenPriv(pScreen); - winCmapPriv(pColormap); - ColormapPtr curpmap = pScreenPriv->pcmapInstalled; - HRESULT ddrval = DD_OK; - - /* Put the X colormap entries into the Windows logical palette */ - ddrval = IDirectDrawPalette_SetEntries(pCmapPriv->lpDDPalette, - 0, - pdefs[0].pixel, - ndef, - pCmapPriv->peColors - + pdefs[0].pixel); - if (FAILED(ddrval)) { - ErrorF("winStoreColorsShadowDD - SetEntries () failed\n"); - return FALSE; - } - - /* Don't install the DirectDraw palette if the colormap is not installed */ - if (pColormap != curpmap) { - return TRUE; - } - - if (!winInstallColormapShadowDD(pColormap)) { - ErrorF("winStoreColorsShadowDD - Failed installing colormap\n"); - return FALSE; - } - - return TRUE; -} - -/* - * Colormap initialization procedure - */ - -static Bool -winCreateColormapShadowDD(ColormapPtr pColormap) -{ - HRESULT ddrval = DD_OK; - ScreenPtr pScreen = pColormap->pScreen; - - winScreenPriv(pScreen); - winCmapPriv(pColormap); - - /* Create a DirectDraw palette */ - ddrval = IDirectDraw2_CreatePalette(pScreenPriv->pdd, - DDPCAPS_8BIT | DDPCAPS_ALLOW256, - pCmapPriv->peColors, - &pCmapPriv->lpDDPalette, NULL); - if (FAILED(ddrval)) { - ErrorF("winCreateColormapShadowDD - CreatePalette failed\n"); - return FALSE; - } - - return TRUE; -} - -/* - * Colormap destruction procedure - */ - -static Bool -winDestroyColormapShadowDD(ColormapPtr pColormap) -{ - winScreenPriv(pColormap->pScreen); - winCmapPriv(pColormap); - HRESULT ddrval = DD_OK; - - /* - * Is colormap to be destroyed the default? - * - * Non-default colormaps should have had winUninstallColormap - * called on them before we get here. The default colormap - * will not have had winUninstallColormap called on it. Thus, - * we need to handle the default colormap in a special way. - */ - if (pColormap->flags & IsDefault) { - winDebug("winDestroyColormapShadowDD - Destroying default " - "colormap\n"); - - /* - * FIXME: Walk the list of all screens, popping the default - * palette out of each screen device context. - */ - - /* Pop the palette out of the primary surface */ - ddrval = IDirectDrawSurface2_SetPalette(pScreenPriv->pddsPrimary, NULL); - if (FAILED(ddrval)) { - ErrorF("winDestroyColormapShadowDD - Failed freeing the " - "default colormap DirectDraw palette.\n"); - return FALSE; - } - - /* Clear our private installed colormap pointer */ - pScreenPriv->pcmapInstalled = NULL; - } - - /* Release the palette */ - IDirectDrawPalette_Release(pCmapPriv->lpDDPalette); - - /* Invalidate the colormap privates */ - pCmapPriv->lpDDPalette = NULL; - - return TRUE; -} - -/* - * Set engine specific functions - */ - -Bool -winSetEngineFunctionsShadowDD(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - - /* Set our pointers */ - pScreenPriv->pwinAllocateFB = winAllocateFBShadowDD; - pScreenPriv->pwinFreeFB = winFreeFBShadowDD; - pScreenPriv->pwinShadowUpdate = winShadowUpdateDD; - pScreenPriv->pwinInitScreen = winInitScreenShadowDD; - pScreenPriv->pwinCloseScreen = winCloseScreenShadowDD; - pScreenPriv->pwinInitVisuals = winInitVisualsShadowDD; - pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowDD; - if (pScreenInfo->fFullScreen) - pScreenPriv->pwinCreateBoundingWindow = - winCreateBoundingWindowFullScreen; - else - pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed; - pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB; - pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowDD; - pScreenPriv->pwinActivateApp = winActivateAppShadowDD; - pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowDD; - pScreenPriv->pwinRealizeInstalledPalette - = winRealizeInstalledPaletteShadowDD; - pScreenPriv->pwinInstallColormap = winInstallColormapShadowDD; - pScreenPriv->pwinStoreColors = winStoreColorsShadowDD; - pScreenPriv->pwinCreateColormap = winCreateColormapShadowDD; - pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowDD; - pScreenPriv->pwinHotKeyAltTab = - (winHotKeyAltTabProcPtr) (void (*)(void)) NoopDDA; - pScreenPriv->pwinCreatePrimarySurface = winCreatePrimarySurfaceShadowDD; - pScreenPriv->pwinReleasePrimarySurface = winReleasePrimarySurfaceShadowDD; -#ifdef XWIN_MULTIWINDOW - pScreenPriv->pwinFinishCreateWindowsWindow = - (winFinishCreateWindowsWindowProcPtr) (void (*)(void)) NoopDDA; -#endif - - return TRUE; -} diff --git a/xorg-server/hw/xwin/winwndproc.c b/xorg-server/hw/xwin/winwndproc.c index a88f7c68d..d260f6ad2 100755 --- a/xorg-server/hw/xwin/winwndproc.c +++ b/xorg-server/hw/xwin/winwndproc.c @@ -162,8 +162,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) * their own mode when they become active. */ if (s_pScreenInfo->fFullScreen - && (s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD - || s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL)) { + || (s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL)) { break; } @@ -186,8 +185,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) */ if (s_pScreenInfo->dwBPP != GetDeviceCaps(s_pScreenPriv->hdcScreen, BITSPIXEL)) { - if ((s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD || - s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL)) { + if (s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL) { /* Cannot display the visual until the depth is restored */ winDebug ("winWindowProc - Disruptive change in depth\n"); |