--- sourceforge.net/trunk/rdesktop/xwin.c 2003/05/19 21:36:33 376 +++ sourceforge.net/trunk/rdesktop/xwin.c 2003/07/01 09:31:25 432 @@ -1,4 +1,4 @@ -/* +/* -*- c-basic-offset: 8 -*- rdesktop: A Remote Desktop Protocol client. User interface services - X Window System Copyright (C) Matthew Chapman 1999-2002 @@ -23,6 +23,7 @@ #include #include #include "rdesktop.h" +#include "xproto.h" extern int width; extern int height; @@ -38,9 +39,10 @@ BOOL mouse_in_wnd; Display *display; +Time last_gesturetime; static int x_socket; static Screen *screen; -static Window wnd; +Window wnd; static GC gc; static Visual *visual; static int depth; @@ -85,6 +87,7 @@ } PixelColour; + #define FILL_RECTANGLE(x,y,cx,cy)\ { \ XFillRectangle(display, wnd, gc, x, y, cx, cy); \ @@ -413,7 +416,7 @@ translate_image(int width, int height, uint8 * data) { int size = width * height * bpp / 8; - uint8 *out = (uint8*)xmalloc(size); + uint8 *out = (uint8 *) xmalloc(size); uint8 *end = out + size; switch (server_bpp) @@ -610,6 +613,7 @@ IM = XOpenIM(display, NULL, NULL, NULL); xkeymap_init(); + xclip_init(); /* todo take this out when high colour is done */ printf("server bpp %d client bpp %d depth %d\n", server_bpp, bpp, depth); @@ -787,18 +791,18 @@ case ClientMessage: /* the window manager told us to quit */ if ((xevent.xclient.message_type == protocol_atom) - && ((Atom)xevent.xclient.data.l[0] == kill_atom)) + && ((Atom) xevent.xclient.data.l[0] == kill_atom)) /* Quit */ return 0; break; case KeyPress: + last_gesturetime = xevent.xkey.time; if (IC != NULL) /* Multi_key compatible version */ { XmbLookupString(IC, - (XKeyPressedEvent *) & - xevent, str, sizeof(str), &keysym, &status); + &xevent.xkey, str, sizeof(str), &keysym, &status); if (!((status == XLookupKeySym) || (status == XLookupBoth))) { error("XmbLookupString failed with status 0x%x\n", @@ -833,6 +837,7 @@ break; case KeyRelease: + last_gesturetime = xevent.xkey.time; XLookupString((XKeyEvent *) & xevent, str, sizeof(str), &keysym, NULL); @@ -857,6 +862,7 @@ /* fall through */ case ButtonRelease: + last_gesturetime = xevent.xbutton.time; button = xkeymap_translate_button(xevent.xbutton.button); if (button == 0) break; @@ -993,6 +999,19 @@ } break; + /* clipboard stuff */ + case SelectionNotify: + xclip_handle_SelectionNotify(&xevent.xselection); + break; + case SelectionRequest: + xclip_handle_SelectionRequest(&xevent.xselectionrequest); + break; + case SelectionClear: + xclip_handle_SelectionClear(); + break; + case PropertyNotify: + xclip_handle_PropertyNotify(&xevent.xproperty); + break; } } /* Keep going */ @@ -1137,10 +1156,10 @@ scanline = (width + 7) / 8; offset = scanline * height; - cursor = (uint8*)xmalloc(offset); + cursor = (uint8 *) xmalloc(offset); memset(cursor, 0, offset); - mask = (uint8*)xmalloc(offset); + mask = (uint8 *) xmalloc(offset); memset(mask, 0, offset); /* approximate AND and XOR masks with a monochrome X pointer */ @@ -1219,7 +1238,7 @@ int i, ncolours = colours->ncolours; if (!owncolmap) { - uint32 *map = (uint32*)xmalloc(sizeof(*colmap) * ncolours); + uint32 *map = (uint32 *) xmalloc(sizeof(*colmap) * ncolours); XColor xentry; XColor xc_cache[256]; uint32 colour; @@ -1297,7 +1316,7 @@ XColor *xcolours, *xentry; Colormap map; - xcolours = (XColor*)xmalloc(sizeof(XColor) * ncolours); + xcolours = (XColor *) xmalloc(sizeof(XColor) * ncolours); for (i = 0; i < ncolours; i++) { entry = &colours->colours[i]; @@ -1327,7 +1346,7 @@ ui_set_colourmap(HCOLOURMAP map) { if (!owncolmap) - colmap = (uint32*)map; + colmap = (uint32 *) map; else XSetWindowColormap(display, wnd, (Colormap) map); } @@ -1372,12 +1391,12 @@ } static uint8 hatch_patterns[] = { - 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, /* 0 - bsHorizontal */ - 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, /* 1 - bsVertical */ - 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, /* 2 - bsFDiagonal */ - 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, /* 3 - bsBDiagonal */ - 0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08, 0x08, /* 4 - bsCross */ - 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 /* 5 - bsDiagCross */ + 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, /* 0 - bsHorizontal */ + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, /* 1 - bsVertical */ + 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, /* 2 - bsFDiagonal */ + 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, /* 3 - bsBDiagonal */ + 0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08, 0x08, /* 4 - bsCross */ + 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 /* 5 - bsDiagCross */ }; void @@ -1398,7 +1417,8 @@ break; case 2: /* Hatch */ - fill = (Pixmap) ui_create_glyph(8, 8, hatch_patterns + brush->pattern[0] * 8); + fill = (Pixmap) ui_create_glyph(8, 8, + hatch_patterns + brush->pattern[0] * 8); SET_FOREGROUND(bgcolour); SET_BACKGROUND(fgcolour); XSetFillStyle(display, gc, FillOpaqueStippled); @@ -1699,3 +1719,4 @@ XFree(image); } +