--- sourceforge.net/trunk/rdesktop/xwin.c 2004/03/25 22:58:45 644 +++ sourceforge.net/trunk/rdesktop/xwin.c 2004/04/30 19:14:15 688 @@ -43,8 +43,9 @@ static int g_x_socket; static Screen *g_screen; Window g_wnd; -uint32 g_embed_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; @@ -57,7 +58,7 @@ static Atom g_protocol_atom, g_kill_atom; static BOOL g_focused; static BOOL g_mouse_in_wnd; -static BOOL g_arch_match = False; /* set to True if RGB XServer and little endian */ +static BOOL g_arch_match = False; /* set to True if RGB XServer and little endian */ /* endianness */ static BOOL g_host_be; @@ -66,7 +67,7 @@ static int g_red_shift_l, g_blue_shift_l, g_green_shift_l; /* software backing store */ -BOOL g_ownbackstore = True; /* We can't rely on external BackingStore */ +extern BOOL g_ownbackstore; static Pixmap g_backstore = 0; /* Moving in single app mode */ @@ -115,7 +116,7 @@ } /* colour maps */ -BOOL g_owncolmap = False; +extern BOOL g_owncolmap; static Colormap g_xcolmap; static uint32 *g_colmap = NULL; @@ -229,6 +230,15 @@ return make_colour(pc); } +#define UNROLL8(stm) { stm stm stm stm stm stm stm stm } +#define REPEAT(stm) \ +{ \ + while (out <= end - 8 * 4) \ + UNROLL8(stm) \ + while (out < end) \ + { stm } \ +} + static void translate8to8(uint8 * data, uint8 * out, uint8 * end) { @@ -241,7 +251,9 @@ { uint16 value; - if (g_xserver_be) + if (g_arch_match) + REPEAT(*(((uint16*)out)++) = g_colmap[*(data++)];) + else if (g_xserver_be) { while (out < end) { @@ -294,7 +306,9 @@ { uint32 value; - if (g_xserver_be) + if (g_arch_match) + REPEAT(*(((uint32*)out)++) = g_colmap[*(data++)];) + else if (g_xserver_be) { while (out < end) { @@ -605,10 +619,13 @@ /* if server and xserver bpp match, */ /* and arch(endian) matches, no need to translate */ /* just return data */ - if (g_depth > 8) - if (g_arch_match) - if (g_depth == g_server_bpp) - return data; + if (g_arch_match) + { + if (g_depth == 15 && g_server_bpp == 15) + return data; + if (g_depth == 16 && g_server_bpp == 16) + return data; + } size = width * height * (g_bpp / 8); out = (uint8 *) xmalloc(size); @@ -953,10 +970,10 @@ XFree(sizehints); } - if ( g_embed_wnd ) - { - XReparentWindow(g_display, g_wnd, (Window)g_embed_wnd, 0, 0); - } + if (g_embed_wnd) + { + XReparentWindow(g_display, g_wnd, (Window) g_embed_wnd, 0, 0); + } input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | VisibilityChangeMask | FocusChangeMask; @@ -989,6 +1006,7 @@ XMaskEvent(g_display, VisibilityChangeMask, &xevent); } while (xevent.type != VisibilityNotify); + g_Unobscured = xevent.xvisibility.state == VisibilityUnobscured; g_focused = False; g_mouse_in_wnd = False; @@ -1006,6 +1024,27 @@ } void +ui_resize_window() +{ + XSizeHints *sizehints; + + sizehints = XAllocSizeHints(); + if (sizehints) + { + sizehints->flags = PMinSize | PMaxSize; + sizehints->min_width = sizehints->max_width = g_width; + sizehints->min_height = sizehints->max_height = g_height; + XSetWMNormalHints(g_display, g_wnd, sizehints); + XFree(sizehints); + } + + if (!(g_fullscreen || g_embed_wnd)) + { + XResizeWindow(g_display, g_wnd, g_width, g_height); + } +} + +void ui_destroy_window(void) { if (g_IC != NULL) @@ -1066,6 +1105,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) @@ -1762,7 +1804,7 @@ { case 0: /* Solid */ SET_FOREGROUND(fgcolour); - FILL_RECTANGLE(x, y, cx, cy); + FILL_RECTANGLE_BACKSTORE(x, y, cx, cy); break; case 2: /* Hatch */ @@ -1773,7 +1815,7 @@ XSetFillStyle(g_display, g_gc, FillOpaqueStippled); XSetStipple(g_display, g_gc, fill); XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin); - FILL_RECTANGLE(x, y, cx, cy); + FILL_RECTANGLE_BACKSTORE(x, y, cx, cy); XSetFillStyle(g_display, g_gc, FillSolid); XSetTSOrigin(g_display, g_gc, 0, 0); ui_destroy_glyph((HGLYPH) fill); @@ -1783,15 +1825,12 @@ for (i = 0; i != 8; i++) ipattern[7 - i] = brush->pattern[i]; fill = (Pixmap) ui_create_glyph(8, 8, ipattern); - SET_FOREGROUND(bgcolour); SET_BACKGROUND(fgcolour); XSetFillStyle(g_display, g_gc, FillOpaqueStippled); XSetStipple(g_display, g_gc, fill); XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin); - - FILL_RECTANGLE(x, y, cx, cy); - + FILL_RECTANGLE_BACKSTORE(x, y, cx, cy); XSetFillStyle(g_display, g_gc, FillSolid); XSetTSOrigin(g_display, g_gc, 0, 0); ui_destroy_glyph((HGLYPH) fill); @@ -1802,6 +1841,9 @@ } RESET_FUNCTION(opcode); + + if (g_ownbackstore) + XCopyArea(g_display, g_backstore, g_wnd, g_gc, x, y, cx, cy, x, y); } void @@ -1812,8 +1854,16 @@ 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 {