--- sourceforge.net/trunk/rdesktop/xwin.c 2002/12/02 22:57:47 281 +++ sourceforge.net/trunk/rdesktop/xwin.c 2003/02/04 05:32:13 309 @@ -31,6 +31,7 @@ extern BOOL grab_keyboard; extern BOOL hide_decorations; extern char title[]; +extern int server_bpp; BOOL enable_compose = False; BOOL focused; BOOL mouse_in_wnd; @@ -62,11 +63,11 @@ #define PROP_MOTIF_WM_HINTS_ELEMENTS 5 typedef struct { - unsigned long flags; - unsigned long functions; - unsigned long decorations; - long inputMode; - unsigned long status; + uint32 flags; + uint32 functions; + uint32 decorations; + sint32 inputMode; + uint32 status; } PropMotifWmHints; @@ -78,7 +79,7 @@ XFillRectangle(display, backstore, gc, x, y, cx, cy); \ } -#define FILL_RECTANGLE_FAST(x,y,cx,cy)\ +#define FILL_RECTANGLE_BACKSTORE(x,y,cx,cy)\ { \ XFillRectangle(display, ownbackstore ? backstore : wnd, gc, x, y, cx, cy); \ } @@ -88,7 +89,7 @@ static Colormap xcolmap; static uint32 *colmap; -#define TRANSLATE(col) ( owncolmap ? col : translate_colour(colmap[col]) ) +#define TRANSLATE(col) ( server_bpp != 8 ? col : owncolmap ? col : translate_colour(colmap[col]) ) #define SET_FOREGROUND(col) XSetForeground(display, gc, TRANSLATE(col)); #define SET_BACKGROUND(col) XSetBackground(display, gc, TRANSLATE(col)); @@ -128,7 +129,7 @@ hintsatom = XInternAtom(display, "_MOTIF_WM_HINTS", False); if (!hintsatom) { - error("Failed to get atom _MOTIF_WM_HINTS\n"); + warning("Failed to get atom _MOTIF_WM_HINTS: probably your window manager does not support MWM hints\n"); return; } @@ -300,10 +301,7 @@ { xcolmap = DefaultColormapOfScreen(screen); if (depth <= 8) - { - printf("You're using a screen depth of 8-bits or lower\n"); - printf("If you get scewed colours, try the -C switch\n"); - } + warning("Screen depth is 8 bits or lower: you may want to use -C for a private colourmap\n"); } gc = XCreateGC(display, RootWindowOfScreen(screen), 0, NULL); @@ -318,13 +316,16 @@ if ((width == 0) || (height == 0)) { /* Fetch geometry from _NET_WORKAREA */ - uint32 xpos, ypos; + uint32 x, y, cx, cy; - if (get_current_workarea(&xpos, &ypos, &width, &height) < 0) + if (get_current_workarea(&x, &y, &cx, &cy) == 0) { - error("Failed to get workarea.\n"); - error("Perhaps your window manager does not support EWMH?\n"); - error("Defaulting to geometry 800x600\n"); + width = cx; + height = cy; + } + else + { + warning("Failed to get workarea: probably your window manager does not support extended hints\n"); width = 800; height = 600; } @@ -607,6 +608,9 @@ break; case MotionNotify: + if (fullscreen && !focused) + XSetInputFocus(display, wnd, RevertToPointerRoot, + CurrentTime); rdp_send_input(time(NULL), RDP_INPUT_MOUSE, MOUSE_FLAG_MOVE, xevent.xmotion.x, xevent.xmotion.y); break; @@ -746,6 +750,24 @@ XImage *image; uint8 *tdata; + if (server_bpp == 16) + { + image = XCreateImage(display, visual, depth, ZPixmap, 0, + (char *) data, width, height, 16, 0); + + if (ownbackstore) + { + XPutImage(display, backstore, gc, image, 0, 0, x, y, cx, cy); + XCopyArea(display, backstore, wnd, gc, x, y, cx, cy, x, y); + } + else + { + XPutImage(display, wnd, gc, image, 0, 0, x, y, cx, cy); + } + + XFree(image); + return; + } tdata = (owncolmap ? data : translate_image(width, height, data)); image = XCreateImage(display, visual, depth, ZPixmap, 0, (char *) tdata, width, height, 8, 0); @@ -1189,7 +1211,7 @@ XSetStipple(display, gc, (Pixmap) glyph); XSetTSOrigin(display, gc, x, y); - FILL_RECTANGLE_FAST(x, y, cx, cy); + FILL_RECTANGLE_BACKSTORE(x, y, cx, cy); XSetFillStyle(display, gc, FillSolid); } @@ -1218,8 +1240,8 @@ }\ if (glyph != NULL)\ {\ - ui_draw_glyph (mixmode, x + (short) glyph->offset,\ - y + (short) glyph->baseline,\ + ui_draw_glyph (mixmode, x + glyph->offset,\ + y + glyph->baseline,\ glyph->width, glyph->height,\ glyph->pixmap, 0, 0, bgcolour, fgcolour);\ if (flags & TEXT2_IMPLICIT_X)\ @@ -1241,11 +1263,11 @@ if (boxcx > 1) { - FILL_RECTANGLE_FAST(boxx, boxy, boxcx, boxcy); + FILL_RECTANGLE_BACKSTORE(boxx, boxy, boxcx, boxcy); } else if (mixmode == MIX_OPAQUE) { - FILL_RECTANGLE_FAST(clipx, clipy, clipcx, clipcy); + FILL_RECTANGLE_BACKSTORE(clipx, clipy, clipcx, clipcy); } /* Paint text, character by character */ @@ -1279,17 +1301,17 @@ else x += text[i + 2]; } - if (i + 2 < length) - i += 3; - else - i += 2; - length -= i; - /* this will move pointer from start to first character after FE command */ - text = &(text[i]); - i = 0; for (j = 0; j < entry->size; j++) DO_GLYPH(((uint8 *) (entry->data)), j); } + if (i + 2 < length) + i += 3; + else + i += 2; + length -= i; + /* this will move pointer from start to first character after FE command */ + text = &(text[i]); + i = 0; break; default: