From 82aa6e1250dfb2024e9c5141e84575408e3b7bb9 Mon Sep 17 00:00:00 2001 From: Michele Cicciotti Date: Thu, 20 Jul 2006 17:11:00 +0000 Subject: [PATCH] Too many changes to list here! just see screenshot: http://img352.imageshack.us/my.php?image=socloseta2.png (not pictured: artifacts due to sometimes-broken handling of window region refreshing) The graphics, mouse and keyboard are virtually done. Mouse wheel works. Still some bugs in the handling of binary raster operation codes, but less than before. Fixed polyline. Fixed all cursor issues. Fully supports text output. Fixed a resource leak where all clipping region were slowly leaked. Now closes cleanly on server disconnect Moving on to more fun things! Many thanks to filip & WaxDragon for the code of the previous Win32 port, it was misleading at times but very useful overall! svn path=/trunk/; revision=23196 --- .../rdesktop-core-tester.cpp | 821 +++++++++++++++--- .../rdesktop-core-tester.vcproj | 4 +- .../rdesktop-core-tester/stdafx.h | 5 + .../applications/tsclient/rdesktop/bitmap.c | 109 ++- .../applications/tsclient/rdesktop/orders.c | 71 +- .../applications/tsclient/rdesktop/proto.h | 4 +- .../tsclient/rdesktop/rdesktop-core.vcproj | 4 +- .../applications/tsclient/rdesktop/rdesktop.h | 1 + .../base/applications/tsclient/rdesktop/rdp.c | 9 +- .../applications/tsclient/rdesktop/secure.c | 4 +- .../applications/tsclient/rdesktop/types.h | 1 - 11 files changed, 868 insertions(+), 165 deletions(-) diff --git a/reactos/base/applications/tsclient/porting-tools/rdesktop-core-tester/rdesktop-core-tester.cpp b/reactos/base/applications/tsclient/porting-tools/rdesktop-core-tester/rdesktop-core-tester.cpp index a75b8009a19..db22a583201 100644 --- a/reactos/base/applications/tsclient/porting-tools/rdesktop-core-tester/rdesktop-core-tester.cpp +++ b/reactos/base/applications/tsclient/porting-tools/rdesktop-core-tester/rdesktop-core-tester.cpp @@ -1,8 +1,30 @@ #include "stdafx.h" +#include + #include "rdesktop/rdesktop.h" #include "rdesktop/proto.h" +template T aligndown(const T& X, const U& align) +{ + return X & ~(T(align) - 1); +} + +template T alignup(const T& X, const U& align) +{ + return aligndown(X + (align - 1), align); +} + +#ifdef _WIN64 +#else + +#undef InterlockedExchangePointer + +#define InterlockedExchangePointer(Target, Value) \ + LongToPtr(InterlockedExchange((LONG volatile *)(Target), PtrToLong(Value))) + +#endif + extern "C" { /* ==== BEGIN POOP ==== */ @@ -83,7 +105,7 @@ extern "C" /* malloc; exit if out of memory */ void * - xmalloc(int size) + xmalloc(size_t size) { void *mem = malloc(size); if (mem == NULL) @@ -98,7 +120,7 @@ extern "C" char * xstrdup(const char *s) { - char *mem = strdup(s); + char *mem = _strdup(s); if (mem == NULL) { perror("strdup"); @@ -109,7 +131,7 @@ extern "C" /* realloc; exit if out of memory */ void * - xrealloc(void *oldmem, int size) + xrealloc(void *oldmem, size_t size) { void *mem; @@ -299,7 +321,9 @@ extern "C" // Globals are totally teh evil, but cut me some slack here HWND hwnd; HBITMAP hbmBuffer; + PVOID pBuffer; HDC hdcBuffer; + UINT wmZMouseWheel; #if 0 // NOTE: we don't really need these with rdesktop.c out of the picture @@ -343,33 +367,120 @@ extern "C" void ui_move_pointer(RDPCLIENT * This, int x, int y) { - // TODO + POINT point; + point.x = x; + point.y = y; + + ClientToScreen(hwnd, &point); + SetCursorPos(point.x, point.y); + } + + HCURSOR hcursor; + + struct Bitmap + { + int width; + int height; + uint8 data[1]; + }; + + static + HBITMAP + win32_create_dib(LONG width, LONG height, WORD bitcount, const BYTE * data) + { + struct b_ + { + BITMAPINFO bmi; + RGBQUAD colormap[256 - ARRAYSIZE(RTL_FIELD_TYPE(BITMAPINFO, bmiColors))]; + } + b; + + b.bmi.bmiHeader.biSize = sizeof(b.bmi.bmiHeader); + b.bmi.bmiHeader.biWidth = width; + b.bmi.bmiHeader.biHeight = height; + b.bmi.bmiHeader.biPlanes = 1; + b.bmi.bmiHeader.biBitCount = bitcount; + b.bmi.bmiHeader.biCompression = BI_RGB; + b.bmi.bmiHeader.biSizeImage = 0; + b.bmi.bmiHeader.biXPelsPerMeter = 0; + b.bmi.bmiHeader.biYPelsPerMeter = 0; + + if(bitcount > 8) + { + b.bmi.bmiHeader.biClrUsed = 0; + b.bmi.bmiHeader.biClrImportant = 0; + } + else + { + b.bmi.bmiHeader.biClrUsed = 2 << bitcount; + b.bmi.bmiHeader.biClrImportant = 2 << bitcount; + + // TODO: palette + } + + HBITMAP hbm = CreateDIBitmap(hdcBuffer, &b.bmi.bmiHeader, CBM_INIT, data, &b.bmi, DIB_RGB_COLORS); + + if(hbm == NULL) + error("CreateDIBitmap %dx%dx%d failed\n", width, height, bitcount); + + return hbm; + } + + static + uint8 * + win32_convert_scanlines(int width, int height, int bitcount, int fromalign, int toalign, const uint8 * data, uint8 ** buffer) + { + assert(width > 0); + assert(height); + assert(bitcount && bitcount <= 32); + assert(fromalign <= toalign); + assert(data); + assert(buffer); + + bool flipped = height < 0; + + if(flipped) + height = - height; + + int bytesperrow = alignup(width * bitcount, 8) / 8; + int fromstride = alignup(bytesperrow, fromalign); + int tostride = alignup(bytesperrow, toalign); + assert(fromstride <= tostride); + + int datasize = tostride * height; + + uint8 * dibits = new(xmalloc(datasize)) uint8; + + const uint8 * src = data; + uint8 * dest = dibits; + + const int pad = tostride - fromstride; + + assert(pad < 4); + __assume(pad < 4); + + if(flipped) + { + dest += (height - 1) * tostride; + tostride = - tostride; + } + + for(int i = 0; i < height; ++ i) + { + memcpy(dest, src, fromstride); + memset(dest + fromstride, 0, pad); + src += fromstride; + dest += tostride; + } + + *buffer = dibits; + return dibits; } HBITMAP ui_create_bitmap(RDPCLIENT * This, int width, int height, uint8 * data) { - void * pBits; - - BITMAPINFOHEADER bmih; - BITMAPINFO bmi; - - bmih.biSize = sizeof(bmih); - bmih.biWidth = width; - bmih.biHeight = - height; - bmih.biPlanes = 1; - bmih.biBitCount = This->server_depth; - bmih.biCompression = BI_RGB; - bmih.biSizeImage = 0; - bmih.biXPelsPerMeter = 0; - bmih.biYPelsPerMeter = 0; - bmih.biClrUsed = 0; - bmih.biClrImportant = 0; - - bmi.bmiHeader = bmih; - memset(bmi.bmiColors, 0, sizeof(bmi.bmiColors)); - - return CreateDIBitmap(hdcBuffer, &bmih, CBM_INIT, data, &bmi, DIB_RGB_COLORS); + return win32_create_dib(width, height, This->server_depth, data); } void @@ -381,44 +492,105 @@ extern "C" HGLYPH ui_create_glyph(RDPCLIENT * This, int width, int height, const uint8 * data) { - // TODO: create 2bpp mask - return 0; + uint8 * databuf = NULL; + uint8 * databits = win32_convert_scanlines(width, height, 1, 1, 2, data, &databuf); + + HBITMAP hbm = CreateBitmap(width, height, 1, 1, databits); + + if(databuf) + xfree(databuf); + + const uint8 * p = data; + int stride = alignup(alignup(width, 8) / 8, 1); + + printf("glyph %p\n", hbm); + + for(int i = 0; i < height; ++ i, p += stride) + { + for(int j = 0; j < width; ++ j) + { + int B = p[j / 8]; + int b = 8 - j % 8 - 1; + + if(B & (1 << b)) + fputs("##", stdout); + else + fputs("..", stdout); + } + + fputc('\n', stdout); + } + + fputc('\n', stdout); + + return hbm; } void ui_destroy_glyph(RDPCLIENT * This, HGLYPH glyph) { - // TODO + DeleteObject(glyph); } HCURSOR ui_create_cursor(RDPCLIENT * This, unsigned int x, unsigned int y, int width, int height, uint8 * andmask, uint8 * xormask) { - return CreateCursor(NULL, x, y, width, height, andmask, xormask); + uint8 * andbuf = NULL; + uint8 * xorbuf = NULL; + + uint8 * andbits = win32_convert_scanlines(width, - height, 1, 2, 4, andmask, &andbuf); + uint8 * xorbits = win32_convert_scanlines(width, height, 24, 2, 4, xormask, &xorbuf); + + HBITMAP hbmMask = CreateBitmap(width, height, 1, 1, andbits); + HBITMAP hbmColor = win32_create_dib(width, height, 24, xorbits); + + ICONINFO iconinfo; + iconinfo.fIcon = FALSE; + iconinfo.xHotspot = x; + iconinfo.yHotspot = y; + iconinfo.hbmMask = hbmMask; + iconinfo.hbmColor = hbmColor; + + HICON icon = CreateIconIndirect(&iconinfo); + + if(icon == NULL) + error("CreateIconIndirect %dx%d failed\n", width, height); + + if(andbuf) + xfree(andbuf); + + if(xorbuf) + xfree(xorbuf); + + DeleteObject(hbmMask); + DeleteObject(hbmColor); + + return icon; } void ui_set_cursor(RDPCLIENT * This, HCURSOR cursor) { - // TODO + hcursor = cursor; } void ui_destroy_cursor(RDPCLIENT * This, HCURSOR cursor) { - DestroyCursor(cursor); + DestroyIcon(cursor); } void ui_set_null_cursor(RDPCLIENT * This) { - // TODO + hcursor = NULL; } HCOLOURMAP ui_create_colourmap(RDPCLIENT * This, COLOURMAP * colours) { + // TODO // TODO: kill HCOLOURMAP/COLOURMAP, use HPALETTE/LOGPALETTE return 0; } @@ -442,9 +614,12 @@ extern "C" { rcClip.left = x; rcClip.top = y; - rcClip.right = x + cx - 1; - rcClip.bottom = y + cy - 1; - SelectObject(hdcBuffer, CreateRectRgnIndirect(&rcClip)); + rcClip.right = x + cx + 1; + rcClip.bottom = y + cy + 1; + + HRGN hrgn = CreateRectRgnIndirect(&rcClip); + SelectClipRgn(hdcBuffer, hrgn); + DeleteObject(hrgn); } void @@ -452,9 +627,9 @@ extern "C" { rcClip.left = 0; rcClip.top = 0; - rcClip.right = This->width; - rcClip.bottom = This->height; - SelectObject(hdcBuffer, CreateRectRgnIndirect(&rcClip)); + rcClip.right = This->width + 1; + rcClip.bottom = This->height + 1; + SelectClipRgn(hdcBuffer, NULL); } void @@ -469,8 +644,17 @@ extern "C" { RECT rcDamage; IntersectRect(&rcDamage, lprc, &rcClip); + +#if 0 + HDC hdc = GetDC(hwnd); + SelectObject(hdc, GetStockObject(NULL_PEN)); + SelectObject(hdc, CreateSolidBrush(RGB(255, 0, 0))); + Rectangle(hdc, rcDamage.left, rcDamage.top, rcDamage.right + 1, rcDamage.bottom + 1); + ReleaseDC(hwnd, hdc); + Sleep(200); +#endif + InvalidateRect(hwnd, &rcDamage, FALSE); - //Sleep(100); } static @@ -522,24 +706,25 @@ extern "C" InvalidateRgn(hwnd, NULL, FALSE); } - /* - TODO: all of the following could probably be implemented this way: - - perform operation on off-screen buffer - - invalidate affected region of the window - */ void ui_paint_bitmap(RDPCLIENT * This, int x, int y, int cx, int cy, int width, int height, uint8 * data) { - BITMAPINFO bmi; - ZeroMemory(&bmi, sizeof(bmi)); + GdiFlush(); - bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader); - bmi.bmiHeader.biWidth = width; - bmi.bmiHeader.biHeight = - height; - bmi.bmiHeader.biPlanes = 1; - bmi.bmiHeader.biBitCount = This->server_depth; + int Bpp = This->server_depth / 8; + int fromstride = alignup(width * Bpp, 4); + int tostride = alignup(This->width * Bpp, 4); + int sizex = cx * Bpp; - StretchDIBits(hdcBuffer, x, y, cx, cy, 0, 0, width, height, data, &bmi, DIB_RGB_COLORS, SRCCOPY); + const uint8 * src = data; + uint8 * dst = (uint8 *)pBuffer + (This->height - y - cy) * tostride + x * Bpp; + + for(int i = 0; i < cy; ++ i) + { + memcpy(dst, src, sizex); + src += fromstride; + dst += tostride; + } win32_repaint_area(This, x, y, cx, cy); } @@ -548,27 +733,80 @@ extern "C" ui_destblt(RDPCLIENT * This, uint8 opcode, /* dest */ int x, int y, int cx, int cy) { - RECT rc; - rc.left = x; - rc.top = y; - rc.right = x + cx; - rc.bottom = y + cy; - - int prev = SetROP2(hdcBuffer, MAKELONG(0, opcode | opcode << 4)); - - FillRect(hdcBuffer, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH)); // use Rectangle instead? - - SetROP2(hdcBuffer, prev); + HGDIOBJ holdbrush = SelectObject(hdcBuffer, GetStockObject(BLACK_BRUSH)); + PatBlt(hdcBuffer, x, y, cx, cy, MAKELONG(0, opcode)); + SelectObject(hdcBuffer, holdbrush); win32_repaint_area(This, x, y, cx, cy); } + static + HBRUSH + win32_create_brush(RDPCLIENT * This, BRUSH * brush, COLORREF fgcolour) + { + switch(brush->style) + { + case BS_SOLID: + case BS_NULL: + case BS_HATCHED: + case BS_PATTERN: + case BS_PATTERN8X8: + break; + + default: + return NULL; + } + + switch(brush->style) + { + case BS_SOLID: + return CreateSolidBrush(fgcolour); + + case BS_HATCHED: + return CreateHatchBrush(brush->pattern[0], fgcolour); + + case BS_NULL: + return (HBRUSH)GetStockObject(NULL_BRUSH); + + case BS_PATTERN: + case BS_PATTERN8X8: + { + uint16 pattern[8]; + + for(size_t i = 0; i < 8; ++ i) + pattern[7 - i] = brush->pattern[i]; + + HBITMAP hpattern = CreateBitmap(8, 8, 1, 1, pattern); + HBRUSH hbr = CreatePatternBrush(hpattern); + DeleteObject(hpattern); + return hbr; + } + + DEFAULT_UNREACHABLE; + } + } + void ui_patblt(RDPCLIENT * This, uint8 opcode, /* dest */ int x, int y, int cx, int cy, /* brush */ BRUSH * brush, int bgcolour, int fgcolour) { - // TODO + HBRUSH hbr = win32_create_brush(This, brush, fgcolour); + + int oldbkcolor = SetBkColor(hdcBuffer, bgcolour); + int oldtextcolor = SetTextColor(hdcBuffer, fgcolour); + POINT oldbrushorg; SetBrushOrgEx(hdcBuffer, brush->xorigin, brush->yorigin, &oldbrushorg); + HGDIOBJ holdbrush = SelectObject(hdcBuffer, hbr); + + PatBlt(hdcBuffer, x, y, cx, cy, MAKELONG(0, opcode)); + + SelectObject(hdcBuffer, holdbrush); + SetBrushOrgEx(hdcBuffer, oldbrushorg.x, oldbrushorg.y, NULL); + SetTextColor(hdcBuffer, oldtextcolor); + SetBkColor(hdcBuffer, oldbkcolor); + + DeleteObject(hbr); + win32_repaint_area(This, x, y, cx, cy); } @@ -577,7 +815,7 @@ extern "C" /* dest */ int x, int y, int cx, int cy, /* src */ int srcx, int srcy) { - BitBlt(hdcBuffer, x, y, cx, cy, hdcBuffer, srcx, srcy, MAKELONG(0, opcode | opcode << 4)); + BitBlt(hdcBuffer, x, y, cx, cy, hdcBuffer, srcx, srcy, MAKELONG(0, opcode)); win32_repaint_area(This, x, y, cx, cy); } @@ -589,9 +827,9 @@ extern "C" HDC hdcSrc = CreateCompatibleDC(hdcBuffer); HGDIOBJ hOld = SelectObject(hdcSrc, src); - BitBlt(hdcBuffer, x, y, cx, cy, hdcSrc, srcx, srcy, MAKELONG(0, opcode | opcode << 4)); + BitBlt(hdcBuffer, x, y, cx, cy, hdcSrc, srcx, srcy, MAKELONG(0, opcode)); - DeleteObject(hOld); + SelectObject(hdcSrc, hOld); DeleteDC(hdcSrc); win32_repaint_area(This, x, y, cx, cy); @@ -603,7 +841,18 @@ extern "C" /* src */ HBITMAP src, int srcx, int srcy, /* brush */ BRUSH * brush, int bgcolour, int fgcolour) { - // TODO + HDC hdcSrc = CreateCompatibleDC(hdcBuffer); + HGDIOBJ hOld = SelectObject(hdcSrc, src); + + //SELECT_BRUSH(brush, bgcolour, fgcolour); + + BitBlt(hdcBuffer, x, y, cx, cy, hdcSrc, srcx, srcy, MAKELONG(0, opcode)); + + //RESET_BRUSH(); + + SelectObject(hdcSrc, hOld); + DeleteDC(hdcSrc); + win32_repaint_area(This, x, y, cx, cy); } @@ -613,20 +862,18 @@ extern "C" /* pen */ PEN * pen) { HPEN hpen = CreatePen(pen->style, pen->width, pen->colour); - HGDIOBJ hOld = SelectObject(hdcBuffer, hpen); - int prevROP = SetROP2(hdcBuffer, opcode); - - POINT prevPos; - MoveToEx(hdcBuffer, startx, starty, &prevPos); + int oldROP2 = SetROP2(hdcBuffer, opcode); + HGDIOBJ holdpen = SelectObject(hdcBuffer, hpen); + POINT oldpos; MoveToEx(hdcBuffer, startx, starty, &oldpos); LineTo(hdcBuffer, endx, endy); - MoveToEx(hdcBuffer, prevPos.x, prevPos.y, NULL); + MoveToEx(hdcBuffer, oldpos.x, oldpos.y, NULL); + SelectObject(hdcBuffer, holdpen); + SetROP2(hdcBuffer, oldROP2); - SetROP2(hdcBuffer, prevROP); - - SelectObject(hdcBuffer, hOld); + DeleteObject(hpen); RECT rcDamage; @@ -661,17 +908,19 @@ extern "C" /* dest */ int x, int y, int cx, int cy, /* brush */ int colour) { - RECT rc; - rc.left = x; - rc.top = y; - rc.right = x + cx; - rc.bottom = y + cy; - HBRUSH hbr = CreateSolidBrush(colour); - FillRect(hdcBuffer, &rc, hbr); // use Rectangle instead? + + HGDIOBJ holdbrush = SelectObject(hdcBuffer, hbr); + HGDIOBJ holdpen = SelectObject(hdcBuffer, GetStockObject(NULL_PEN)); + + Rectangle(hdcBuffer, x, y, x + cx + 1, y + cy + 1); + + SelectObject(hdcBuffer, holdpen); + SelectObject(hdcBuffer, holdbrush); + DeleteObject(hbr); - win32_repaint_rect(This, &rc); + win32_repaint_area(This, x, y, cx, cy); } void @@ -680,13 +929,19 @@ extern "C" /* dest */ POINT * point, int npoints, /* brush */ BRUSH * brush, int bgcolour, int fgcolour) { - // TODO: create brush, set fg&bg + HBRUSH hbr = win32_create_brush(This, brush, fgcolour); - int oldRop = SetROP2(hdcBuffer, opcode); + int oldbkcolor = SetBkColor(hdcBuffer, bgcolour); + int oldtextcolor = SetTextColor(hdcBuffer, fgcolour); int oldFillMode = SetPolyFillMode(hdcBuffer, fillmode); + HGDIOBJ holdbrush = SelectObject(hdcBuffer, hbr); + Polygon(hdcBuffer, point, npoints); + + SelectObject(hdcBuffer, holdbrush); SetPolyFillMode(hdcBuffer, oldFillMode); - SetROP2(hdcBuffer, oldRop); + SetTextColor(hdcBuffer, oldtextcolor); + SetBkColor(hdcBuffer, oldbkcolor); win32_repaint_poly(This, point, npoints, 0); } @@ -696,12 +951,26 @@ extern "C" /* dest */ POINT * points, int npoints, /* pen */ PEN * pen) { + POINT last = points[0]; + + for(int i = 1; i < npoints; ++ i) + { + points[i].x += last.x; + points[i].y += last.y; + last = points[i]; + } + HPEN hpen = CreatePen(pen->style, pen->width, pen->colour); - HGDIOBJ hOld = SelectObject(hdcBuffer, hpen); - int oldRop = SetROP2(hdcBuffer, opcode); + + int oldROP2 = SetROP2(hdcBuffer, opcode); + HGDIOBJ holdpen = SelectObject(hdcBuffer, hpen); + Polyline(hdcBuffer, points, npoints); - SetROP2(hdcBuffer, oldRop); - SelectObject(hdcBuffer, hOld); + + SelectObject(hdcBuffer, holdpen); + SetROP2(hdcBuffer, oldROP2); + + DeleteObject(hpen); win32_repaint_poly(This, points, npoints, pen->width); } @@ -712,13 +981,30 @@ extern "C" /* dest */ int x, int y, int cx, int cy, /* brush */ BRUSH * brush, int bgcolour, int fgcolour) { -#if 0 switch(fillmode) { - case 0: // outline // HOW? HOW? WITH WHAT PEN? - case 1: // filled // TODO + case 0: // outline + { + HPEN hpen = CreatePen(PS_SOLID, 1, fgcolour); + + int oldROP2 = SetROP2(hdcBuffer, opcode); + HGDIOBJ holdPen = SelectObject(hdcBuffer, hpen); + + Ellipse(hdcBuffer, x, y, x + cx, y + cy); + + SelectObject(hdcBuffer, holdPen); + SetROP2(hdcBuffer, oldROP2); + + DeleteObject(hpen); + } + + break; + + case 1: + // TODO + break; } -#endif + win32_repaint_area(This, x, y, cx, cy); } @@ -728,28 +1014,188 @@ extern "C" /* src */ HGLYPH glyph, int srcx, int srcy, int bgcolour, int fgcolour) { - // TODO!!! + HBITMAP hbmGlyph = (HBITMAP)glyph; + HDC hdcGlyph = CreateCompatibleDC(hdcBuffer); + HGDIOBJ hOld = SelectObject(hdcGlyph, hbmGlyph); + + switch(mixmode) + { + case MIX_TRANSPARENT: + { + /* + ROP is DSPDxax: + - where the glyph (S) is white, D is set to the foreground color (P) + - where the glyph (S) is black, D is left untouched + + This paints a transparent glyph in the specified color + */ + HBRUSH hbr = CreateSolidBrush(fgcolour); + HGDIOBJ holdbrush = SelectObject(hdcBuffer, hbr); + BitBlt(hdcBuffer, x, y, cx, cy, hdcGlyph, srcx, srcy, MAKELONG(0, 0xe2)); + SelectObject(hdcBuffer, holdbrush); + DeleteObject(hbr); + } + + break; + + case MIX_OPAQUE: + { + /* Curiously, glyphs are inverted (white-on-black) */ + int oldbkcolor = SetBkColor(hdcBuffer, fgcolour); + int oldtextcolor = SetTextColor(hdcBuffer, bgcolour); + BitBlt(hdcBuffer, x, y, cx, cy, hdcGlyph, srcx, srcy, SRCCOPY); + SetTextColor(hdcBuffer, oldtextcolor); + SetBkColor(hdcBuffer, oldbkcolor); + } + + break; + } + + SelectObject(hdcGlyph, hOld); + DeleteDC(hdcGlyph); + + win32_repaint_area(This, x, y, cx, cy); } +#define DO_GLYPH(ttext,idx) \ +{\ + glyph = cache_get_font (This, font, ttext[idx]);\ + if (!(flags & TEXT2_IMPLICIT_X))\ + {\ + xyoffset = ttext[++idx];\ + if ((xyoffset & 0x80))\ + {\ + if (flags & TEXT2_VERTICAL)\ + y += ttext[idx+1] | (ttext[idx+2] << 8);\ + else\ + x += ttext[idx+1] | (ttext[idx+2] << 8);\ + idx += 2;\ + }\ + else\ + {\ + if (flags & TEXT2_VERTICAL)\ + y += xyoffset;\ + else\ + x += xyoffset;\ + }\ + }\ + if (glyph != NULL)\ + {\ + ui_draw_glyph (This, mixmode, x + (short) glyph->offset,\ + y + (short) glyph->baseline,\ + glyph->width, glyph->height,\ + glyph->pixmap, 0, 0, bgcolour, fgcolour);\ + if (flags & TEXT2_IMPLICIT_X)\ + x += glyph->width;\ + }\ +} + void ui_draw_text(RDPCLIENT * This, uint8 font, uint8 flags, uint8 opcode, int mixmode, int x, int y, int clipx, int clipy, int clipcx, int clipcy, int boxx, int boxy, int boxcx, int boxcy, BRUSH * brush, int bgcolour, int fgcolour, uint8 * text, uint8 length) { - // TODO!!! + FONTGLYPH * glyph; + int i, j, xyoffset; + DATABLOB *entry; + + HBRUSH hbr = CreateSolidBrush(bgcolour); + HGDIOBJ holdbrush = SelectObject(hdcBuffer, hbr); + HGDIOBJ holdpen = SelectObject(hdcBuffer, GetStockObject(NULL_PEN)); + + if (boxcx > 1) + Rectangle(hdcBuffer, boxx, boxy, boxx + boxcx + 1, boxy + boxcy + 1); + else if (mixmode == MIX_OPAQUE) + Rectangle(hdcBuffer, clipx, clipy, clipx + clipcx + 1, clipy + clipcy + 1); + + SelectObject(hdcBuffer, holdpen); + SelectObject(hdcBuffer, holdbrush); + + DeleteObject(hbr); + + if(boxcx > 1) + win32_repaint_area(This, boxx, boxy, boxcx, boxcy); + else + win32_repaint_area(This, clipx, clipy, clipcx, clipcy); + + /* Paint text, character by character */ + for (i = 0; i < length;) + { + switch (text[i]) + { + case 0xff: + /* At least two bytes needs to follow */ + if (i + 3 > length) + { + warning("Skipping short 0xff command:"); + for (j = 0; j < length; j++) + fprintf(stderr, "%02x ", text[j]); + fprintf(stderr, "\n"); + i = length = 0; + break; + } + cache_put_text(This, text[i + 1], text, text[i + 2]); + i += 3; + length -= i; + /* this will move pointer from start to first character after FF command */ + text = &(text[i]); + i = 0; + break; + + case 0xfe: + /* At least one byte needs to follow */ + if (i + 2 > length) + { + warning("Skipping short 0xfe command:"); + for (j = 0; j < length; j++) + fprintf(stderr, "%02x ", text[j]); + fprintf(stderr, "\n"); + i = length = 0; + break; + } + entry = cache_get_text(This, text[i + 1]); + if (entry->data != NULL) + { + if ((((uint8 *) (entry->data))[1] == 0) + && (!(flags & TEXT2_IMPLICIT_X)) && (i + 2 < length)) + { + if (flags & TEXT2_VERTICAL) + y += text[i + 2]; + else + x += text[i + 2]; + } + 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: + DO_GLYPH(text, i); + i++; + break; + } + } } void ui_desktop_save(RDPCLIENT * This, uint32 offset, int x, int y, int cx, int cy) { - // TODO (use GetDIBits) + // TODO } void ui_desktop_restore(RDPCLIENT * This, uint32 offset, int x, int y, int cx, int cy) { - // TODO (use SetDIBitsToDevice) + // TODO win32_repaint_whole(This); } @@ -766,6 +1212,24 @@ extern "C" } }; +static +void +mstsc_mousewheel(RDPCLIENT * This, int value, LPARAM lparam) +{ + uint16 button; + + if(value < 0) + button = MOUSE_FLAG_BUTTON5; + else + button = MOUSE_FLAG_BUTTON4; + + if(value < 0) + value = - value; + + for(int click = 0; click < value; click += WHEEL_DELTA) + rdp_send_input(This, GetTickCount(), RDP_INPUT_MOUSE, button | MOUSE_FLAG_DOWN, LOWORD(lparam), HIWORD(lparam)); +} + static LRESULT CALLBACK @@ -783,64 +1247,132 @@ mstsc_WndProc switch(uMsg) { + case WM_CLOSE: + DestroyWindow(hwnd); + break; + + // FIXME: temporary + case WM_DESTROY: + PostQuitMessage(0); + break; + + /* Initialization */ case WM_CREATE: This = static_cast(reinterpret_cast(lparam)->lpCreateParams); SetWindowLongPtr(hwnd, GWLP_USERDATA, PtrToLong(This)); break; + /* Painting */ + case WM_PRINTCLIENT: + if(wparam == 0) + break; + case WM_PAINT: - // Obscenely simple code for now... { - PAINTSTRUCT ps; - HDC hdc = BeginPaint(hwnd, &ps); + HDC hdc = (HDC)wparam; - BitBlt - ( - hdc, - ps.rcPaint.left, - ps.rcPaint.top, - ps.rcPaint.right - ps.rcPaint.left, - ps.rcPaint.bottom - ps.rcPaint.top, - hdcBuffer, - ps.rcPaint.left, - ps.rcPaint.top, - SRCCOPY - ); + // A DC was provided: print the whole client area into it + if(hdc) + { + RECT rc; + GetClientRect(hwnd, &rc); + BitBlt(hdc, 0, 0, rc.right, rc.bottom, hdcBuffer, 0, 0, SRCCOPY); + } + // Otherwise, we're refreshing to screen + else + { + PAINTSTRUCT ps; + hdc = BeginPaint(hwnd, &ps); - EndPaint(hwnd, &ps); + BitBlt + ( + hdc, + ps.rcPaint.left, + ps.rcPaint.top, + ps.rcPaint.right - ps.rcPaint.left, + ps.rcPaint.bottom - ps.rcPaint.top, + hdcBuffer, + ps.rcPaint.left, + ps.rcPaint.top, + SRCCOPY + ); + + EndPaint(hwnd, &ps); + } } break; + /* Keyboard stuff */ case WM_SYSKEYDOWN: case WM_KEYDOWN: - rdp_send_input - ( - This, - GetMessageTime(), - RDP_INPUT_SCANCODE, - RDP_KEYPRESS | (lparam & 0x1000000 ? KBD_FLAG_EXT : 0), - LOBYTE(HIWORD(lparam)), - 0 - ); - + rdp_send_input(This, GetMessageTime(), RDP_INPUT_SCANCODE, RDP_KEYPRESS | (lparam & 0x1000000 ? KBD_FLAG_EXT : 0), LOBYTE(HIWORD(lparam)), 0); break; case WM_SYSKEYUP: case WM_KEYUP: - rdp_send_input - ( - This, - GetMessageTime(), - RDP_INPUT_SCANCODE, - RDP_KEYRELEASE | (lparam & 0x1000000 ? KBD_FLAG_EXT : 0), - LOBYTE(HIWORD(lparam)), - 0 - ); + rdp_send_input(This, GetMessageTime(), RDP_INPUT_SCANCODE, RDP_KEYRELEASE | (lparam & 0x1000000 ? KBD_FLAG_EXT : 0), LOBYTE(HIWORD(lparam)), 0); + break; + + /* Mouse stuff */ + // Cursor shape + case WM_SETCURSOR: + if(LOWORD(lparam) == HTCLIENT) + { + SetCursor(hcursor); + return TRUE; + } break; + // Movement + case WM_MOUSEMOVE: + if(This->sendmotion || wparam & (MK_LBUTTON | MK_RBUTTON | MK_MBUTTON | MK_XBUTTON1 | MK_XBUTTON2)) + rdp_send_input(This, GetMessageTime(), RDP_INPUT_MOUSE, MOUSE_FLAG_MOVE, LOWORD(lparam), HIWORD(lparam)); + + break; + + // Buttons + // TODO: X buttons + case WM_LBUTTONDOWN: + rdp_send_input(This, GetMessageTime(), RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1 | MOUSE_FLAG_DOWN, LOWORD(lparam), HIWORD(lparam)); + break; + + case WM_RBUTTONDOWN: + rdp_send_input(This, GetMessageTime(), RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2 | MOUSE_FLAG_DOWN, LOWORD(lparam), HIWORD(lparam)); + break; + + case WM_MBUTTONDOWN: + rdp_send_input(This, GetMessageTime(), RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON3 | MOUSE_FLAG_DOWN, LOWORD(lparam), HIWORD(lparam)); + break; + + case WM_LBUTTONUP: + rdp_send_input(This, GetMessageTime(), RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, LOWORD(lparam), HIWORD(lparam)); + break; + + case WM_RBUTTONUP: + rdp_send_input(This, GetMessageTime(), RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2, LOWORD(lparam), HIWORD(lparam)); + break; + + case WM_MBUTTONUP: + rdp_send_input(This, GetMessageTime(), RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON3, LOWORD(lparam), HIWORD(lparam)); + break; + + // Wheel + case WM_MOUSEWHEEL: + mstsc_mousewheel(This, (SHORT)HIWORD(wparam), lparam); + break; + default: + /* Registered messages */ + // Z-Mouse wheel support - you know, just in case + if(uMsg == wmZMouseWheel) + { + mstsc_mousewheel(This, (int)wparam, lparam); + break; + } + + /* Unhandled messages */ return DefWindowProc(hwnd, uMsg, wparam, lparam); } @@ -857,14 +1389,15 @@ mstsc_ProtocolIOThread { RDPCLIENT * This = static_cast(lpArgument); - strcpy(This->username, "Hyperion"); + strcpy(This->username, "Administrator"); DWORD dw = sizeof(This->hostname); GetComputerNameA(This->hostname, &dw); uint32 flags = RDP_LOGON_NORMAL | RDP_LOGON_COMPRESSION | RDP_LOGON_COMPRESSION2; - rdp_connect(This, "10.0.0.3", flags, "", "", "", ""); + //rdp_connect(This, "10.0.0.3", flags, "", "", "", ""); + rdp_connect(This, "192.168.7.232", flags, "", "", "", ""); hdcBuffer = CreateCompatibleDC(NULL); @@ -881,9 +1414,7 @@ mstsc_ProtocolIOThread bmi.bmiHeader.biClrUsed = 0; // TODO! palette displays bmi.bmiHeader.biClrImportant = 0; // TODO! palette displays - void * p; - - hbmBuffer = CreateDIBSection(hdcBuffer, &bmi, DIB_RGB_COLORS, &p, NULL, 0); + hbmBuffer = CreateDIBSection(hdcBuffer, &bmi, DIB_RGB_COLORS, &pBuffer, NULL, 0); SelectObject(hdcBuffer, hbmBuffer); @@ -897,6 +1428,8 @@ mstsc_ProtocolIOThread rdp_main_loop(This, &deactivated, &ext_disc_reason); + SendMessage(hwnd, WM_CLOSE, 0, 0); + return 0; } @@ -936,8 +1469,8 @@ int wmain() This->bitmap_cache_precache = True; This->encryption = True; This->packet_encryption = True; - This->desktop_save = True; - This->polygon_ellipse_orders = True; + This->desktop_save = False; // True; + This->polygon_ellipse_orders = False; // = True; This->fullscreen = False; This->grab_keyboard = True; This->hide_decorations = False; @@ -957,6 +1490,8 @@ int wmain() This->cache.bmpcache_mru[1] = NOT_SET; This->cache.bmpcache_mru[2] = NOT_SET; + hcursor = NULL; + WNDCLASS wc; ZeroMemory(&wc, sizeof(wc)); @@ -964,6 +1499,8 @@ int wmain() wc.hbrBackground = static_cast(GetStockObject(HOLLOW_BRUSH)); wc.lpszClassName = TEXT("MissTosca_Desktop"); + wmZMouseWheel = RegisterWindowMessage(MSH_MOUSEWHEEL); + ATOM a = RegisterClass(&wc); hwnd = CreateWindow diff --git a/reactos/base/applications/tsclient/porting-tools/rdesktop-core-tester/rdesktop-core-tester.vcproj b/reactos/base/applications/tsclient/porting-tools/rdesktop-core-tester/rdesktop-core-tester.vcproj index 44256e90d41..84dc5cb1d98 100644 --- a/reactos/base/applications/tsclient/porting-tools/rdesktop-core-tester/rdesktop-core-tester.vcproj +++ b/reactos/base/applications/tsclient/porting-tools/rdesktop-core-tester/rdesktop-core-tester.vcproj @@ -61,7 +61,7 @@ /> + #include #include #include diff --git a/reactos/base/applications/tsclient/rdesktop/bitmap.c b/reactos/base/applications/tsclient/rdesktop/bitmap.c index 5ea484a4d99..26964b0f02e 100644 --- a/reactos/base/applications/tsclient/rdesktop/bitmap.c +++ b/reactos/base/applications/tsclient/rdesktop/bitmap.c @@ -23,7 +23,7 @@ /* comment out #define BITMAP_SPEED_OVER_SIZE below for one slower function */ /* j@american-data.com */ -#define BITMAP_SPEED_OVER_SIZE +//#define BITMAP_SPEED_OVER_SIZE /* indent is confused by this file */ /* *INDENT-OFF* */ @@ -73,14 +73,22 @@ static BOOL bitmap_decompress1(uint8 * output, int width, int height, uint8 * input, int size) { uint8 *end = input + size; - uint8 *prevline = NULL, *line = NULL; - int opcode, count, offset, isfillormix, x = width; + uint8 *prevline = NULL; + int opcode, count, offset, isfillormix; int lastopcode = -1, insertmix = False, bicolour = False; uint8 code; uint8 colour1 = 0, colour2 = 0; uint8 mixmask, mask = 0; uint8 mix = 0xff; int fom_mask = 0; +#if 0 + uint8 *line = NULL; + int x = width; +#else + uint8 *line = output; + int x = 0; + int y = 0; +#endif while (input < end) { @@ -167,12 +175,27 @@ bitmap_decompress1(uint8 * output, int width, int height, uint8 * input, int siz { if (x >= width) { +#if 0 if (height <= 0) +#else + if (y >= height) +#endif return False; x = 0; + +#if 0 height--; +#else + y ++; +#endif + prevline = line; + +#if 0 line = output + height * width; +#else + line = output + y * width; +#endif } switch (opcode) { @@ -271,14 +294,22 @@ static BOOL bitmap_decompress2(uint8 * output, int width, int height, uint8 * input, int size) { uint8 *end = input + size; - uint16 *prevline = NULL, *line = NULL; - int opcode, count, offset, isfillormix, x = width; + uint16 *prevline = NULL; + int opcode, count, offset, isfillormix; int lastopcode = -1, insertmix = False, bicolour = False; uint8 code; uint16 colour1 = 0, colour2 = 0; uint8 mixmask, mask = 0; uint16 mix = 0xffff; int fom_mask = 0; +#if 0 + uint8 *line = NULL; + int x = width; +#else + uint8 *line = output; + int x = 0; + int y = 0; +#endif while (input < end) { @@ -365,12 +396,27 @@ bitmap_decompress2(uint8 * output, int width, int height, uint8 * input, int siz { if (x >= width) { +#if 0 if (height <= 0) +#else + if (y >= height) +#endif return False; x = 0; + +#if 0 height--; +#else + y ++; +#endif + prevline = line; + +#if 0 line = ((uint16 *) output) + height * width; +#else + line = ((uint16 *) output) + y * width; +#endif } switch (opcode) { @@ -470,14 +516,22 @@ static BOOL bitmap_decompress3(uint8 * output, int width, int height, uint8 * input, int size) { uint8 *end = input + size; - uint8 *prevline = NULL, *line = NULL; - int opcode, count, offset, isfillormix, x = width; + uint8 *prevline = NULL; + int opcode, count, offset, isfillormix; int lastopcode = -1, insertmix = False, bicolour = False; uint8 code; uint8 colour1[3] = {0, 0, 0}, colour2[3] = {0, 0, 0}; uint8 mixmask, mask = 0; uint8 mix[3] = {0xff, 0xff, 0xff}; int fom_mask = 0; +#if 0 + uint8 *line = NULL; + int x = width; +#else + uint8 *line = output; + int x = 0; + int y = 0; +#endif while (input < end) { @@ -571,12 +625,27 @@ bitmap_decompress3(uint8 * output, int width, int height, uint8 * input, int siz { if (x >= width) { +#if 0 if (height <= 0) +#else + if (y >= height) +#endif return False; x = 0; + +#if 0 height--; +#else + y ++; +#endif + prevline = line; + +#if 0 line = output + height * (width * 3); +#else + line = output + y * (width * 3); +#endif } switch (opcode) { @@ -782,14 +851,22 @@ static BOOL bitmap_decompressx(uint8 *output, int width, int height, uint8 *input, int size, int Bpp) { uint8 *end = input + size; - uint8 *prevline = NULL, *line = NULL; - int opcode, count, offset, isfillormix, x = width; + uint8 *prevline = NULL; + int opcode, count, offset, isfillormix; int lastopcode = -1, insertmix = False, bicolour = False; uint8 code; uint32 colour1 = 0, colour2 = 0; uint8 mixmask, mask = 0; uint32 mix = 0xffffffff; int fom_mask = 0; +#if 0 + uint8 *line = NULL; + int x = width; +#else + uint8 *line = output; + int x = 0; + int y = 0; +#endif while (input < end) { @@ -885,14 +962,28 @@ bitmap_decompressx(uint8 *output, int width, int height, uint8 *input, int size, { if (x >= width) { +#if 0 if (height <= 0) +#else + if (y >= height) +#endif return False; x = 0; + +#if 0 height--; +#else + y ++; +#endif prevline = line; + +#if 0 line = output + height * width * Bpp; +#else + line = output + y * width * Bpp; +#endif } switch (opcode) diff --git a/reactos/base/applications/tsclient/rdesktop/orders.c b/reactos/base/applications/tsclient/rdesktop/orders.c index d8e70b253b2..517633a6662 100644 --- a/reactos/base/applications/tsclient/rdesktop/orders.c +++ b/reactos/base/applications/tsclient/rdesktop/orders.c @@ -188,7 +188,11 @@ process_destblt(RDPCLIENT * This, STREAM s, DESTBLT_ORDER * os, uint32 present, DEBUG(("DESTBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d)\n", os->opcode, os->x, os->y, os->cx, os->cy)); +#if 0 ui_destblt(This, ROP2_S(os->opcode), os->x, os->y, os->cx, os->cy); +#else + ui_destblt(This, os->opcode, os->x, os->y, os->cx, os->cy); +#endif } /* Process a pattern blt order */ @@ -221,8 +225,13 @@ process_patblt(RDPCLIENT * This, STREAM s, PATBLT_ORDER * os, uint32 present, BO DEBUG(("PATBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d,bs=%d,bg=0x%x,fg=0x%x)\n", os->opcode, os->x, os->y, os->cx, os->cy, os->brush.style, os->bgcolour, os->fgcolour)); +#if 0 ui_patblt(This, ROP2_P(os->opcode), os->x, os->y, os->cx, os->cy, &os->brush, os->bgcolour, os->fgcolour); +#else + ui_patblt(This, os->opcode, os->x, os->y, os->cx, os->cy, + &os->brush, os->bgcolour, os->fgcolour); +#endif } /* Process a screen blt order */ @@ -253,7 +262,11 @@ process_screenblt(RDPCLIENT * This, STREAM s, SCREENBLT_ORDER * os, uint32 prese DEBUG(("SCREENBLT(op=0x%x,x=%d,y=%d,cx=%d,cy=%d,srcx=%d,srcy=%d)\n", os->opcode, os->x, os->y, os->cx, os->cy, os->srcx, os->srcy)); +#if 0 ui_screenblt(This, ROP2_S(os->opcode), os->x, os->y, os->cx, os->cy, os->srcx, os->srcy); +#else + ui_screenblt(This, os->opcode, os->x, os->y, os->cx, os->cy, os->srcx, os->srcy); +#endif } /* Process a line order */ @@ -292,7 +305,11 @@ process_line(RDPCLIENT * This, STREAM s, LINE_ORDER * os, uint32 present, BOOL d return; } +#if 0 ui_line(This, os->opcode - 1, os->startx, os->starty, os->endx, os->endy, &os->pen); +#else + ui_line(This, os->opcode, os->startx, os->starty, os->endx, os->endy, &os->pen); +#endif } /* Process an opaque rectangle order */ @@ -414,7 +431,11 @@ process_memblt(RDPCLIENT * This, STREAM s, MEMBLT_ORDER * os, uint32 present, BO if (bitmap == NULL) return; +#if 0 ui_memblt(This, ROP2_S(os->opcode), os->x, os->y, os->cx, os->cy, bitmap, os->srcx, os->srcy); +#else + ui_memblt(This, os->opcode, os->x, os->y, os->cx, os->cy, bitmap, os->srcx, os->srcy); +#endif } /* Process a 3-way blt order */ @@ -547,8 +568,13 @@ process_polygon(RDPCLIENT * This, STREAM s, POLYGON_ORDER * os, uint32 present, } if (next - 1 == os->npoints) +#if 0 ui_polygon(This, os->opcode - 1, os->fillmode, points, os->npoints + 1, NULL, 0, os->fgcolour); +#else + ui_polygon(This, os->opcode, os->fillmode, points, os->npoints + 1, NULL, 0, + os->fgcolour); +#endif else error("polygon parse error\n"); @@ -632,8 +658,13 @@ process_polygon2(RDPCLIENT * This, STREAM s, POLYGON2_ORDER * os, uint32 present } if (next - 1 == os->npoints) +#if 0 ui_polygon(This, os->opcode - 1, os->fillmode, points, os->npoints + 1, &os->brush, os->bgcolour, os->fgcolour); +#else + ui_polygon(This, os->opcode, os->fillmode, points, os->npoints + 1, + &os->brush, os->bgcolour, os->fgcolour); +#endif else error("polygon2 parse error\n"); @@ -711,7 +742,11 @@ process_polyline(RDPCLIENT * This, STREAM s, POLYLINE_ORDER * os, uint32 present } if (next - 1 == os->lines) +#if 0 ui_polyline(This, os->opcode - 1, points, os->lines + 1, &pen); +#else + ui_polyline(This, os->opcode, points, os->lines + 1, &pen); +#endif else error("polyline parse error\n"); @@ -746,8 +781,13 @@ process_ellipse(RDPCLIENT * This, STREAM s, ELLIPSE_ORDER * os, uint32 present, DEBUG(("ELLIPSE(l=%d,t=%d,r=%d,b=%d,op=0x%x,fm=%d,fg=0x%x)\n", os->left, os->top, os->right, os->bottom, os->opcode, os->fillmode, os->fgcolour)); +#if 0 ui_ellipse(This, os->opcode - 1, os->fillmode, os->left, os->top, os->right - os->left, os->bottom - os->top, NULL, 0, os->fgcolour); +#else + ui_ellipse(This, os->opcode, os->fillmode, os->left, os->top, os->right - os->left, + os->bottom - os->top, NULL, 0, os->fgcolour); +#endif } /* Process an ellipse2 order */ @@ -784,8 +824,13 @@ process_ellipse2(RDPCLIENT * This, STREAM s, ELLIPSE2_ORDER * os, uint32 present os->left, os->top, os->right, os->bottom, os->opcode, os->fillmode, os->brush.style, os->bgcolour, os->fgcolour)); +#if 0 ui_ellipse(This, os->opcode - 1, os->fillmode, os->left, os->top, os->right - os->left, os->bottom - os->top, &os->brush, os->bgcolour, os->fgcolour); +#else + ui_ellipse(This, os->opcode, os->fillmode, os->left, os->top, os->right - os->left, + os->bottom - os->top, &os->brush, os->bgcolour, os->fgcolour); +#endif } /* Process a text order */ @@ -859,11 +904,19 @@ process_text2(RDPCLIENT * This, STREAM s, TEXT2_ORDER * os, uint32 present, BOOL DEBUG(("\n")); +#if 0 ui_draw_text(This, os->font, os->flags, os->opcode - 1, os->mixmode, os->x, os->y, os->clipleft, os->cliptop, os->clipright - os->clipleft, os->clipbottom - os->cliptop, os->boxleft, os->boxtop, os->boxright - os->boxleft, os->boxbottom - os->boxtop, &os->brush, os->bgcolour, os->fgcolour, os->text, os->length); +#else + ui_draw_text(This, os->font, os->flags, os->opcode, os->mixmode, os->x, os->y, + os->clipleft, os->cliptop, os->clipright - os->clipleft, + os->clipbottom - os->cliptop, os->boxleft, os->boxtop, + os->boxright - os->boxleft, os->boxbottom - os->boxtop, + &os->brush, os->bgcolour, os->fgcolour, os->text, os->length); +#endif } /* Process a raw bitmap cache order */ @@ -887,15 +940,22 @@ process_raw_bmpcache(RDPCLIENT * This, STREAM s) in_uint8p(s, data, bufsize); DEBUG(("RAW_BMPCACHE(cx=%d,cy=%d,id=%d,idx=%d)\n", width, height, cache_id, cache_idx)); +#if 0 inverted = (uint8 *) xmalloc(width * height * Bpp); for (y = 0; y < height; y++) { memcpy(&inverted[(height - y - 1) * (width * Bpp)], &data[y * (width * Bpp)], width * Bpp); } +#endif +#if 0 bitmap = ui_create_bitmap(This, width, height, inverted); xfree(inverted); +#else + bitmap = ui_create_bitmap(This, width, height, data); +#endif + cache_put_bitmap(This, cache_id, cache_idx, bitmap); } @@ -1000,10 +1060,10 @@ process_bmpcache2(RDPCLIENT * This, STREAM s, uint16 flags, BOOL compressed) DEBUG(("BMPCACHE2(compr=%d,flags=%x,cx=%d,cy=%d,id=%d,idx=%d,Bpp=%d,bs=%d)\n", compressed, flags, width, height, cache_id, cache_idx, Bpp, bufsize)); - bmpdata = (uint8 *) xmalloc(width * height * Bpp); - if (compressed) { + bmpdata = (uint8 *) xmalloc(width * height * Bpp); + if (!bitmap_decompress(bmpdata, width, height, data, bufsize, Bpp)) { DEBUG(("Failed to decompress bitmap data\n")); @@ -1013,9 +1073,13 @@ process_bmpcache2(RDPCLIENT * This, STREAM s, uint16 flags, BOOL compressed) } else { +#if 0 for (y = 0; y < height; y++) memcpy(&bmpdata[(height - y - 1) * (width * Bpp)], &data[y * (width * Bpp)], width * Bpp); +#else + bmpdata = data; +#endif } bitmap = ui_create_bitmap(This, width, height, bmpdata); @@ -1032,7 +1096,8 @@ process_bmpcache2(RDPCLIENT * This, STREAM s, uint16 flags, BOOL compressed) DEBUG(("process_bmpcache2: ui_create_bitmap failed\n")); } - xfree(bmpdata); + if (compressed) + xfree(bmpdata); } /* Process a colourmap cache order */ diff --git a/reactos/base/applications/tsclient/rdesktop/proto.h b/reactos/base/applications/tsclient/rdesktop/proto.h index bc1d94fa808..952f187194f 100644 --- a/reactos/base/applications/tsclient/rdesktop/proto.h +++ b/reactos/base/applications/tsclient/rdesktop/proto.h @@ -110,9 +110,9 @@ BOOL pstcache_init(RDPCLIENT * This, uint8 cache_id); /* rdesktop.c */ int main(int argc, char *argv[]); void generate_random(uint8 * random); -void *xmalloc(int size); +void *xmalloc(size_t size); char *xstrdup(const char *s); -void *xrealloc(void *oldmem, int size); +void *xrealloc(void *oldmem, size_t size); void xfree(void *mem); void error(char *format, ...); void warning(char *format, ...); diff --git a/reactos/base/applications/tsclient/rdesktop/rdesktop-core.vcproj b/reactos/base/applications/tsclient/rdesktop/rdesktop-core.vcproj index 4b9e1569b5b..5cad05a66b1 100644 --- a/reactos/base/applications/tsclient/rdesktop/rdesktop-core.vcproj +++ b/reactos/base/applications/tsclient/rdesktop/rdesktop-core.vcproj @@ -39,7 +39,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories=""C:\Documents and Settings\All Users\Documenti\openssl-0.9.8b\inc32"" - PreprocessorDefinitions="WIN32;_DEBUG;_LIB;WITH_DEBUG;" + PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -100,7 +100,7 @@ end - s->p - 8; #if WITH_DEBUG - DEBUG(("Sending encrypted packet:\n")); - hexdump(s->p + 8, datalen); + //DEBUG(("Sending encrypted packet:\n")); + //hexdump(s->p + 8, datalen); #endif sec_sign(s->p, 8, This->secure.sign_key, This->secure.rc4_key_len, s->p + 8, datalen); diff --git a/reactos/base/applications/tsclient/rdesktop/types.h b/reactos/base/applications/tsclient/rdesktop/types.h index 705373f9f59..54a459639d1 100644 --- a/reactos/base/applications/tsclient/rdesktop/types.h +++ b/reactos/base/applications/tsclient/rdesktop/types.h @@ -92,7 +92,6 @@ typedef struct _PEN } PEN; -// TODO: nuke, use LOGBRUSH + pattern[8] typedef struct _BRUSH { uint8 xorigin;