--- sourceforge.net/trunk/rdesktop/xwin.c 2004/02/14 23:20:24 606 +++ sourceforge.net/trunk/rdesktop/xwin.c 2004/03/03 10:46:35 620 @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -63,7 +64,7 @@ static int g_red_shift_l, g_blue_shift_l, g_green_shift_l; /* software backing store */ -static BOOL g_ownbackstore; +BOOL g_ownbackstore = True; /* We can't rely on external BackingStore */ static Pixmap g_backstore = 0; /* Moving in single app mode */ @@ -168,12 +169,9 @@ split_colour15(uint32 colour) { PixelColour rv; - rv.red = (colour & 0x7c00) >> 10; - rv.red = (rv.red * 0xff) / 0x1f; - rv.green = (colour & 0x03e0) >> 5; - rv.green = (rv.green * 0xff) / 0x1f; - rv.blue = (colour & 0x1f); - rv.blue = (rv.blue * 0xff) / 0x1f; + rv.red = (colour & 0x7c00) >> 7; + rv.green = (colour & 0x03e0) >> 2; + rv.blue = (colour & 0x001f) << 3; return rv; } @@ -181,12 +179,9 @@ split_colour16(uint32 colour) { PixelColour rv; - rv.red = (colour & 0xf800) >> 11; - rv.red = (rv.red * 0xff) / 0x1f; - rv.green = (colour & 0x07e0) >> 5; - rv.green = (rv.green * 0xff) / 0x3f; - rv.blue = (colour & 0x001f); - rv.blue = (rv.blue * 0xff) / 0x1f; + rv.red = (colour & 0xf800) >> 8; + rv.green = (colour & 0x07e0) >> 3; + rv.blue = (colour & 0x001f) << 3; return rv; } @@ -195,8 +190,8 @@ { PixelColour rv; rv.blue = (colour & 0xff0000) >> 16; - rv.green = (colour & 0xff00) >> 8; - rv.red = (colour & 0xff); + rv.green = (colour & 0x00ff00) >> 8; + rv.red = (colour & 0x0000ff); return rv; } @@ -791,8 +786,11 @@ warning("Screen depth is 8 bits or lower: you may want to use -C for a private colourmap\n"); } - if (DoesBackingStore(g_screen) != Always) + if ((!g_ownbackstore) && (DoesBackingStore(g_screen) != Always)) + { + warning("External BackingStore not available, using internal\n"); g_ownbackstore = True; + } test = 1; g_host_be = !(BOOL) (*(uint8 *) (&test)); @@ -1779,9 +1777,15 @@ /* src */ int srcx, int srcy) { SET_FUNCTION(opcode); - XCopyArea(g_display, g_wnd, g_wnd, g_gc, srcx, srcy, cx, cy, x, y); if (g_ownbackstore) + { + XCopyArea(g_display, g_backstore, g_wnd, g_gc, srcx, srcy, cx, cy, x, y); XCopyArea(g_display, g_backstore, g_backstore, g_gc, srcx, srcy, cx, cy, x, y); + } + else + { + XCopyArea(g_display, g_wnd, g_wnd, g_gc, srcx, srcy, cx, cy, x, y); + } RESET_FUNCTION(opcode); } @@ -1918,6 +1922,12 @@ SET_FOREGROUND(bgcolour); + /* Sometimes, the boxcx value is something really large, like + 32691. This makes XCopyArea fail with Xvnc. The code below + is a quick fix. */ + if (boxx + boxcx > g_width) + boxcx = g_width - boxx; + if (boxcx > 1) { FILL_RECTANGLE_BACKSTORE(boxx, boxy, boxcx, boxcy);