--- sourceforge.net/trunk/rdesktop/xwin.c 2004/04/26 23:14:07 680 +++ sourceforge.net/trunk/rdesktop/xwin.c 2004/06/04 15:01:36 708 @@ -45,6 +45,7 @@ Window g_wnd; extern uint32 g_embed_wnd; BOOL g_enable_compose = False; +BOOL g_Unobscured; /* used for screenblt */ static GC g_gc = NULL; static Visual *g_visual; static int g_depth; @@ -171,9 +172,9 @@ split_colour15(uint32 colour) { PixelColour rv; - rv.red = (colour & 0x7c00) >> 7; - rv.green = (colour & 0x03e0) >> 2; - rv.blue = (colour & 0x001f) << 3; + rv.red = ((colour >> 7) & 0xf8) | ((colour >> 12) & 0x7); + rv.green = ((colour >> 2) & 0xf8) | ((colour >> 8) & 0x7); + rv.blue = ((colour << 3) & 0xf8) | ((colour >> 2) & 0x7); return rv; } @@ -181,9 +182,9 @@ split_colour16(uint32 colour) { PixelColour rv; - rv.red = (colour & 0xf800) >> 8; - rv.green = (colour & 0x07e0) >> 3; - rv.blue = (colour & 0x001f) << 3; + rv.red = ((colour >> 8) & 0xf8) | ((colour >> 13) & 0x7); + rv.green = ((colour >> 3) & 0xfc) | ((colour >> 9) & 0x3); + rv.blue = ((colour << 3) & 0xf8) | ((colour >> 2) & 0x7); return rv; } @@ -251,26 +252,28 @@ uint16 value; if (g_arch_match) - REPEAT(*(((uint16*)out)++) = g_colmap[*(data++)];) - else if (g_xserver_be) + REPEAT(*((uint16 *) out) = g_colmap[*(data++)]; + out += 2;) + else +if (g_xserver_be) +{ + while (out < end) { - while (out < end) - { - value = (uint16) g_colmap[*(data++)]; - *(out++) = value >> 8; - *(out++) = value; - } + value = (uint16) g_colmap[*(data++)]; + *(out++) = value >> 8; + *(out++) = value; } - else +} +else +{ + while (out < end) { - while (out < end) - { - value = (uint16) g_colmap[*(data++)]; - *(out++) = value; - *(out++) = value >> 8; - } + value = (uint16) g_colmap[*(data++)]; + *(out++) = value; + *(out++) = value >> 8; } } +} /* little endian - conversion happens when colourmap is built */ static void @@ -306,30 +309,32 @@ uint32 value; if (g_arch_match) - REPEAT(*(((uint32*)out)++) = g_colmap[*(data++)];) - else if (g_xserver_be) + REPEAT(*((uint32 *) out) = g_colmap[*(data++)]; + out += 4;) + else +if (g_xserver_be) +{ + while (out < end) { - while (out < end) - { - value = g_colmap[*(data++)]; - *(out++) = value >> 24; - *(out++) = value >> 16; - *(out++) = value >> 8; - *(out++) = value; - } + value = g_colmap[*(data++)]; + *(out++) = value >> 24; + *(out++) = value >> 16; + *(out++) = value >> 8; + *(out++) = value; } - else +} +else +{ + while (out < end) { - while (out < end) - { - value = g_colmap[*(data++)]; - *(out++) = value; - *(out++) = value >> 8; - *(out++) = value >> 16; - *(out++) = value >> 24; - } + value = g_colmap[*(data++)]; + *(out++) = value; + *(out++) = value >> 8; + *(out++) = value >> 16; + *(out++) = value >> 24; } } +} static void translate15to16(uint16 * data, uint8 * out, uint8 * end) @@ -1005,6 +1010,7 @@ XMaskEvent(g_display, VisibilityChangeMask, &xevent); } while (xevent.type != VisibilityNotify); + g_Unobscured = xevent.xvisibility.state == VisibilityUnobscured; g_focused = False; g_mouse_in_wnd = False; @@ -1025,6 +1031,7 @@ ui_resize_window() { XSizeHints *sizehints; + Pixmap bs; sizehints = XAllocSizeHints(); if (sizehints) @@ -1040,6 +1047,17 @@ { XResizeWindow(g_display, g_wnd, g_width, g_height); } + + /* create new backstore pixmap */ + if (g_backstore != 0) + { + bs = XCreatePixmap(g_display, g_wnd, g_width, g_height, g_depth); + XSetForeground(g_display, g_gc, BlackPixelOfScreen(g_screen)); + XFillRectangle(g_display, bs, g_gc, 0, 0, g_width, g_height); + XCopyArea(g_display, g_backstore, bs, g_gc, 0, 0, g_width, g_height, 0, 0); + XFreePixmap(g_display, g_backstore); + g_backstore = bs; + } } void @@ -1103,6 +1121,9 @@ switch (xevent.type) { + case VisibilityNotify: + g_Unobscured = xevent.xvisibility.state == VisibilityUnobscured; + break; case ClientMessage: /* the window manager told us to quit */ if ((xevent.xclient.message_type == g_protocol_atom) @@ -1849,8 +1870,18 @@ SET_FUNCTION(opcode); 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); + if (g_Unobscured) + { + XCopyArea(g_display, g_wnd, 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_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 {