--- sourceforge.net/trunk/rdesktop/xwin.c 2002/07/29 20:17:10 77 +++ sourceforge.net/trunk/rdesktop/xwin.c 2002/08/03 22:28:05 87 @@ -217,8 +217,7 @@ It seems to work alright anyway, though. */ if (IC != NULL) { - if (XGetICValues(IC, XNFilterEvents, &filtered_events, NULL) - != NULL) + if (XGetICValues(IC, XNFilterEvents, &filtered_events, NULL) != NULL) { error("Failed to obtain XNFilterEvents value from IC\n"); filtered_events = 0; @@ -241,6 +240,24 @@ } } +BOOL +ui_init() +{ + Screen *screen; + display = XOpenDisplay(NULL); + if (display == NULL) + { + error("Failed to open display\n"); + return False; + } + if (fullscreen) + { + screen = DefaultScreenOfDisplay(display); + width = WidthOfScreen(screen); + height = HeightOfScreen(screen); + } + return True; +} BOOL ui_create_window(char *title) @@ -253,14 +270,7 @@ Screen *screen; uint16 test; int i; - - display = XOpenDisplay(NULL); - - if (display == NULL) - { - error("Failed to open display\n"); - return False; - } + XEvent xevent; x_socket = ConnectionNumber(display); screen = DefaultScreenOfDisplay(display); @@ -274,8 +284,7 @@ desirable, e.g. 24 bits->32 bits. */ while (i--) { - if ((pfm[i].depth == depth) - && (pfm[i].bits_per_pixel > bpp)) + if ((pfm[i].depth == depth) && (pfm[i].bits_per_pixel > bpp)) { bpp = pfm[i].bits_per_pixel; } @@ -322,8 +331,7 @@ wnd = XCreateWindow(display, RootWindowOfScreen(screen), 0, 0, width, height, 0, CopyFromParent, InputOutput, CopyFromParent, - CWBackingStore | CWBackPixel | CWOverrideRedirect, - &attribs); + CWBackingStore | CWBackPixel | CWOverrideRedirect, &attribs); XStoreName(display, wnd, title); @@ -347,9 +355,8 @@ xkeymap_init2(); - input_mask = - KeyPressMask | KeyReleaseMask | ButtonPressMask | - ButtonReleaseMask; + input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | + VisibilityChangeMask; if (grab_keyboard) input_mask |= EnterWindowMask | LeaveWindowMask; if (sendmotion) @@ -370,6 +377,18 @@ XMapWindow(display, wnd); + /* Wait for VisibilityNotify Event */ + for (;;) { + XNextEvent(display, &xevent); + if (xevent.type == VisibilityNotify) + break; + } + + /* clear the window so that cached data is not viewed upon start... */ + XSetBackground(display, gc, 0); + XSetForeground(display, gc, 0); + FILL_RECTANGLE(0, 0, width, height); + return True; } @@ -414,7 +433,7 @@ { if (enable_compose && (XFilterEvent(&xevent, None) == True)) { - DEBUG_KBD("Filtering event\n"); + DEBUG_KBD(("Filtering event\n")); continue; } @@ -429,73 +448,59 @@ { XmbLookupString(IC, (XKeyPressedEvent *) & - xevent, str, - sizeof(str), &keysym, - &status); - if (! - ((status == XLookupKeySym) - || (status == XLookupBoth))) + xevent, str, sizeof(str), &keysym, &status); + if (!((status == XLookupKeySym) || (status == XLookupBoth))) { - error("XmbLookupString failed with status 0x%x\n", status); + error("XmbLookupString failed with status 0x%x\n", + status); break; } } else { /* Plain old XLookupString */ - DEBUG_KBD - ("No input context, using XLookupString\n"); + DEBUG_KBD(("No input context, using XLookupString\n")); XLookupString((XKeyEvent *) & xevent, - str, sizeof(str), - &keysym, NULL); + str, sizeof(str), &keysym, NULL); } ksname = get_ksname(keysym); - DEBUG_KBD - ("\nKeyPress for (keysym 0x%lx, %s)\n", - keysym, ksname); + DEBUG_KBD(("\nKeyPress for (keysym 0x%lx, %s)\n", keysym, ksname)); if (inhibit_key(keysym)) { - DEBUG_KBD("Inhibiting key\n"); + DEBUG_KBD(("Inhibiting key\n")); break; } tr = xkeymap_translate_key(keysym, - xevent.xkey. - keycode, - xevent.xkey.state); + xevent.xkey.keycode, xevent.xkey.state); ensure_remote_modifiers(ev_time, tr); if (tr.scancode == 0) break; - rdp_send_scancode(ev_time, RDP_KEYPRESS, - tr.scancode); + rdp_send_scancode(ev_time, RDP_KEYPRESS, tr.scancode); break; case KeyRelease: XLookupString((XKeyEvent *) & xevent, str, sizeof(str), &keysym, NULL); ksname = get_ksname(keysym); - DEBUG_KBD - ("\nKeyRelease for (keysym 0x%lx, %s)\n", - keysym, ksname); + DEBUG_KBD(("\nKeyRelease for (keysym 0x%lx, %s)\n", keysym, + ksname)); if (inhibit_key(keysym)) break; tr = xkeymap_translate_key(keysym, - xevent.xkey. - keycode, - xevent.xkey.state); + xevent.xkey.keycode, xevent.xkey.state); if (tr.scancode == 0) break; - rdp_send_scancode(ev_time, RDP_KEYRELEASE, - tr.scancode); + rdp_send_scancode(ev_time, RDP_KEYRELEASE, tr.scancode); break; case ButtonPress: @@ -503,23 +508,17 @@ /* fall through */ case ButtonRelease: - button = xkeymap_translate_button(xevent. - xbutton. - button); + button = xkeymap_translate_button(xevent.xbutton.button); if (button == 0) break; rdp_send_input(ev_time, RDP_INPUT_MOUSE, - flags | button, - xevent.xbutton.x, - xevent.xbutton.y); + flags | button, xevent.xbutton.x, xevent.xbutton.y); break; case MotionNotify: rdp_send_input(ev_time, RDP_INPUT_MOUSE, - MOUSE_FLAG_MOVE, - xevent.xmotion.x, - xevent.xmotion.y); + MOUSE_FLAG_MOVE, xevent.xmotion.x, xevent.xmotion.y); break; case FocusIn: @@ -527,19 +526,15 @@ case EnterNotify: if (grab_keyboard) XGrabKeyboard(display, wnd, True, - GrabModeAsync, - GrabModeAsync, - CurrentTime); + GrabModeAsync, GrabModeAsync, CurrentTime); break; case FocusOut: /* reset keys */ rdp_send_input(ev_time, RDP_INPUT_SCANCODE, - KBD_FLAG_DOWN | KBD_FLAG_UP, - SCANCODE_CHAR_LCTRL, 0); + KBD_FLAG_DOWN | KBD_FLAG_UP, SCANCODE_CHAR_LCTRL, 0); rdp_send_input(ev_time, RDP_INPUT_SCANCODE, - KBD_FLAG_DOWN | KBD_FLAG_UP, - SCANCODE_CHAR_LALT, 0); + KBD_FLAG_DOWN | KBD_FLAG_UP, SCANCODE_CHAR_LALT, 0); /* fall through */ case LeaveNotify: if (grab_keyboard) @@ -619,8 +614,7 @@ } void -ui_paint_bitmap(int x, int y, int cx, int cy, int width, int height, - uint8 * data) +ui_paint_bitmap(int x, int y, int cx, int cy, int width, int height, uint8 * data) { XImage *image; uint8 *tdata; @@ -904,12 +898,12 @@ SET_BACKGROUND(fgcolour); XSetFillStyle(display, gc, FillOpaqueStippled); XSetStipple(display, gc, fill); - XSetTSOrigin(display, gc, brush->xorigin, - brush->yorigin); + XSetTSOrigin(display, gc, brush->xorigin, brush->yorigin); FILL_RECTANGLE(x, y, cx, cy); XSetFillStyle(display, gc, FillSolid); + XSetTSOrigin(display, gc, 0, 0); ui_destroy_glyph((HGLYPH) fill); break; @@ -928,8 +922,7 @@ SET_FUNCTION(opcode); XCopyArea(display, wnd, wnd, gc, srcx, srcy, cx, cy, x, y); if (ownbackstore) - XCopyArea(display, backstore, backstore, gc, srcx, srcy, cx, - cy, x, y); + XCopyArea(display, backstore, backstore, gc, srcx, srcy, cx, cy, x, y); RESET_FUNCTION(opcode); } @@ -941,8 +934,7 @@ SET_FUNCTION(opcode); XCopyArea(display, (Pixmap) src, wnd, gc, srcx, srcy, cx, cy, x, y); if (ownbackstore) - XCopyArea(display, (Pixmap) src, backstore, gc, srcx, srcy, - cx, cy, x, y); + XCopyArea(display, (Pixmap) src, backstore, gc, srcx, srcy, cx, cy, x, y); RESET_FUNCTION(opcode); } @@ -959,22 +951,18 @@ { case 0x69: /* PDSxxn */ ui_memblt(ROP2_XOR, x, y, cx, cy, src, srcx, srcy); - ui_patblt(ROP2_NXOR, x, y, cx, cy, brush, bgcolour, - fgcolour); + ui_patblt(ROP2_NXOR, x, y, cx, cy, brush, bgcolour, fgcolour); break; case 0xb8: /* PSDPxax */ - ui_patblt(ROP2_XOR, x, y, cx, cy, brush, bgcolour, - fgcolour); + ui_patblt(ROP2_XOR, x, y, cx, cy, brush, bgcolour, fgcolour); ui_memblt(ROP2_AND, x, y, cx, cy, src, srcx, srcy); - ui_patblt(ROP2_XOR, x, y, cx, cy, brush, bgcolour, - fgcolour); + ui_patblt(ROP2_XOR, x, y, cx, cy, brush, bgcolour, fgcolour); break; case 0xc0: /* PSa */ ui_memblt(ROP2_COPY, x, y, cx, cy, src, srcx, srcy); - ui_patblt(ROP2_AND, x, y, cx, cy, brush, bgcolour, - fgcolour); + ui_patblt(ROP2_AND, x, y, cx, cy, brush, bgcolour, fgcolour); break; default: @@ -1015,8 +1003,7 @@ SET_BACKGROUND(bgcolour); XSetFillStyle(display, gc, - (mixmode == - MIX_TRANSPARENT) ? FillStippled : FillOpaqueStippled); + (mixmode == MIX_TRANSPARENT) ? FillStippled : FillOpaqueStippled); XSetStipple(display, gc, (Pixmap) glyph); XSetTSOrigin(display, gc, x, y); @@ -1086,8 +1073,7 @@ { case 0xff: if (i + 2 < length) - cache_put_text(text[i + 1], text, - text[i + 2]); + cache_put_text(text[i + 1], text, text[i + 2]); else { error("this shouldn't be happening\n"); @@ -1104,8 +1090,7 @@ if (entry != NULL) { if ((((uint8 *) (entry->data))[1] == - 0) - && (!(flags & TEXT2_IMPLICIT_X))) + 0) && (!(flags & TEXT2_IMPLICIT_X))) { if (flags & TEXT2_VERTICAL) y += text[i + 2]; @@ -1121,9 +1106,7 @@ text = &(text[i]); i = 0; for (j = 0; j < entry->size; j++) - DO_GLYPH(((uint8 *) (entry-> - data)), - j); + DO_GLYPH(((uint8 *) (entry->data)), j); } break; @@ -1145,21 +1128,18 @@ if (ownbackstore) { - image = XGetImage(display, backstore, x, y, cx, cy, AllPlanes, - ZPixmap); + image = XGetImage(display, backstore, x, y, cx, cy, AllPlanes, ZPixmap); } else { pix = XCreatePixmap(display, wnd, cx, cy, depth); XCopyArea(display, wnd, pix, gc, x, y, cx, cy, 0, 0); - image = XGetImage(display, pix, 0, 0, cx, cy, AllPlanes, - ZPixmap); + image = XGetImage(display, pix, 0, 0, cx, cy, AllPlanes, ZPixmap); XFreePixmap(display, pix); } offset *= bpp / 8; - cache_put_desktop(offset, cx, cy, image->bytes_per_line, bpp / 8, - (uint8 *) image->data); + cache_put_desktop(offset, cx, cy, image->bytes_per_line, bpp / 8, (uint8 *) image->data); XDestroyImage(image); } @@ -1176,8 +1156,7 @@ return; image = XCreateImage(display, visual, depth, ZPixmap, 0, - (char *) data, cx, cy, BitmapPad(display), - cx * bpp / 8); + (char *) data, cx, cy, BitmapPad(display), cx * bpp / 8); if (ownbackstore) {