Add a ui_select to xwin.c to reduce latency.
Remove extraneous error messages - only report at lowest level. Endianness and IRIX compile fixes. git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@32 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
parent
dc7bfecb7a
commit
e867eb6fd1
2
Makefile
2
Makefile
@ -45,7 +45,7 @@ proto:
|
|||||||
cproto -DMAKE_PROTO -o proto.h *.c
|
cproto -DMAKE_PROTO -o proto.h *.c
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o crypto/*.o *~
|
rm -f *.o crypto/*.o *~ rdesktop
|
||||||
|
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
.SUFFIXES: .c .o
|
.SUFFIXES: .c .o
|
||||||
|
@ -379,8 +379,8 @@ int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p,
|
|||||||
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
|
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
|
||||||
int BN_mod_exp2_mont(BIGNUM *r, BIGNUM *a1, BIGNUM *p1,BIGNUM *a2,
|
int BN_mod_exp2_mont(BIGNUM *r, BIGNUM *a1, BIGNUM *p1,BIGNUM *a2,
|
||||||
BIGNUM *p2,BIGNUM *m,BN_CTX *ctx,BN_MONT_CTX *m_ctx);
|
BIGNUM *p2,BIGNUM *m,BN_CTX *ctx,BN_MONT_CTX *m_ctx);
|
||||||
int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, BIGNUM *p,
|
int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
|
||||||
BIGNUM *m,BN_CTX *ctx);
|
const BIGNUM *m,BN_CTX *ctx);
|
||||||
int BN_mask_bits(BIGNUM *a,int n);
|
int BN_mask_bits(BIGNUM *a,int n);
|
||||||
int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
|
int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
|
||||||
#ifndef NO_FP_API
|
#ifndef NO_FP_API
|
||||||
|
@ -795,7 +795,7 @@ err:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The old fallback, simple version :-) */
|
/* The old fallback, simple version :-) */
|
||||||
int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,
|
int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m,
|
||||||
BN_CTX *ctx)
|
BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
int i,j,bits,ret=0,wstart,wend,window,wvalue,ts=0;
|
int i,j,bits,ret=0,wstart,wend,window,wvalue,ts=0;
|
||||||
|
22
iso.c
22
iso.c
@ -52,13 +52,13 @@ iso_recv_msg(uint8 *code)
|
|||||||
|
|
||||||
s = tcp_recv(4);
|
s = tcp_recv(4);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return False;
|
return NULL;
|
||||||
|
|
||||||
in_uint8(s, version);
|
in_uint8(s, version);
|
||||||
if (version != 3)
|
if (version != 3)
|
||||||
{
|
{
|
||||||
error("TPKT v%d\n", version);
|
error("TPKT v%d\n", version);
|
||||||
return False;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
in_uint8s(s, 1); /* pad */
|
in_uint8s(s, 1); /* pad */
|
||||||
@ -66,7 +66,7 @@ iso_recv_msg(uint8 *code)
|
|||||||
|
|
||||||
s = tcp_recv(length - 4);
|
s = tcp_recv(length - 4);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return False;
|
return NULL;
|
||||||
|
|
||||||
in_uint8s(s, 1); /* hdrlen */
|
in_uint8s(s, 1); /* hdrlen */
|
||||||
in_uint8(s, *code);
|
in_uint8(s, *code);
|
||||||
@ -121,10 +121,13 @@ iso_recv()
|
|||||||
uint8 code;
|
uint8 code;
|
||||||
|
|
||||||
s = iso_recv_msg(&code);
|
s = iso_recv_msg(&code);
|
||||||
if ((s == NULL) || (code != ISO_PDU_DT))
|
if (s == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (code != ISO_PDU_DT)
|
||||||
{
|
{
|
||||||
error("expected DT, got %d\n", code);
|
error("expected DT, got 0x%x\n", code);
|
||||||
return False;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
@ -141,9 +144,12 @@ iso_connect(char *server)
|
|||||||
|
|
||||||
iso_send_msg(ISO_PDU_CR);
|
iso_send_msg(ISO_PDU_CR);
|
||||||
|
|
||||||
if ((iso_recv_msg(&code) == NULL) || (code != ISO_PDU_CC))
|
if (iso_recv_msg(&code) == NULL)
|
||||||
|
return False;
|
||||||
|
|
||||||
|
if (code != ISO_PDU_CC)
|
||||||
{
|
{
|
||||||
error("expected CC, got %d\n", code);
|
error("expected CC, got 0x%x\n", code);
|
||||||
tcp_disconnect();
|
tcp_disconnect();
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
2
proto.h
2
proto.h
@ -63,7 +63,7 @@ void tcp_disconnect(void);
|
|||||||
/* xwin.c */
|
/* xwin.c */
|
||||||
BOOL ui_create_window(char *title);
|
BOOL ui_create_window(char *title);
|
||||||
void ui_destroy_window(void);
|
void ui_destroy_window(void);
|
||||||
void ui_process_events(void);
|
void ui_select(int rdp_socket);
|
||||||
void ui_move_pointer(int x, int y);
|
void ui_move_pointer(int x, int y);
|
||||||
HBITMAP ui_create_bitmap(int width, int height, uint8 *data);
|
HBITMAP ui_create_bitmap(int width, int height, uint8 *data);
|
||||||
void ui_paint_bitmap(int x, int y, int cx, int cy, int width, int height, uint8 *data);
|
void ui_paint_bitmap(int x, int y, int cx, int cy, int width, int height, uint8 *data);
|
||||||
|
@ -224,6 +224,7 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
printf("Connection successful.\n");
|
printf("Connection successful.\n");
|
||||||
rdp_main_loop();
|
rdp_main_loop();
|
||||||
|
printf("Disconnecting...\n");
|
||||||
ui_destroy_window();
|
ui_destroy_window();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
36
tcp.c
36
tcp.c
@ -56,11 +56,10 @@ tcp_send(STREAM s)
|
|||||||
|
|
||||||
while (total < length)
|
while (total < length)
|
||||||
{
|
{
|
||||||
sent = write(sock, s->data + total, length - total);
|
sent = send(sock, s->data + total, length - total, 0);
|
||||||
|
|
||||||
if (sent <= 0)
|
if (sent <= 0)
|
||||||
{
|
{
|
||||||
error("write: %s\n", strerror(errno));
|
error("send: %s\n", strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,9 +71,7 @@ tcp_send(STREAM s)
|
|||||||
STREAM
|
STREAM
|
||||||
tcp_recv(int length)
|
tcp_recv(int length)
|
||||||
{
|
{
|
||||||
int ret, rcvd = 0;
|
int rcvd = 0;
|
||||||
struct timeval tv;
|
|
||||||
fd_set rfds;
|
|
||||||
|
|
||||||
if (length > in.size)
|
if (length > in.size)
|
||||||
{
|
{
|
||||||
@ -86,28 +83,17 @@ tcp_recv(int length)
|
|||||||
|
|
||||||
while (length > 0)
|
while (length > 0)
|
||||||
{
|
{
|
||||||
ui_process_events();
|
ui_select(sock);
|
||||||
|
|
||||||
FD_ZERO(&rfds);
|
rcvd = recv(sock, in.end, length, 0);
|
||||||
FD_SET(sock, &rfds);
|
if (rcvd == -1)
|
||||||
tv.tv_sec = 0;
|
|
||||||
tv.tv_usec = 100;
|
|
||||||
|
|
||||||
ret = select(sock + 1, &rfds, NULL, NULL, &tv);
|
|
||||||
|
|
||||||
if (ret)
|
|
||||||
{
|
{
|
||||||
rcvd = read(sock, in.end, length);
|
error("recv: %s\n", strerror(errno));
|
||||||
|
return NULL;
|
||||||
if (rcvd <= 0)
|
|
||||||
{
|
|
||||||
error("read: %s\n", strerror(errno));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
in.end += rcvd;
|
|
||||||
length -= rcvd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
in.end += rcvd;
|
||||||
|
length -= rcvd;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ∈
|
return ∈
|
||||||
|
99
xwin.c
99
xwin.c
@ -21,6 +21,7 @@
|
|||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <errno.h>
|
||||||
#include "rdesktop.h"
|
#include "rdesktop.h"
|
||||||
|
|
||||||
extern int width;
|
extern int width;
|
||||||
@ -29,12 +30,18 @@ extern BOOL sendmotion;
|
|||||||
extern BOOL fullscreen;
|
extern BOOL fullscreen;
|
||||||
|
|
||||||
static Display *display;
|
static Display *display;
|
||||||
|
static int x_socket;
|
||||||
static Window wnd;
|
static Window wnd;
|
||||||
static GC gc;
|
static GC gc;
|
||||||
static Visual *visual;
|
static Visual *visual;
|
||||||
static int depth;
|
static int depth;
|
||||||
static int bpp;
|
static int bpp;
|
||||||
|
|
||||||
|
/* endianness */
|
||||||
|
static BOOL host_be;
|
||||||
|
static BOOL xserver_be;
|
||||||
|
|
||||||
|
/* software backing store */
|
||||||
static BOOL ownbackstore;
|
static BOOL ownbackstore;
|
||||||
static Pixmap backstore;
|
static Pixmap backstore;
|
||||||
|
|
||||||
@ -45,12 +52,13 @@ static Pixmap backstore;
|
|||||||
XFillRectangle(display, backstore, gc, x, y, cx, cy); \
|
XFillRectangle(display, backstore, gc, x, y, cx, cy); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* colour maps */
|
||||||
static BOOL owncolmap;
|
static BOOL owncolmap;
|
||||||
static Colormap xcolmap;
|
static Colormap xcolmap;
|
||||||
static uint32 white;
|
static uint32 white;
|
||||||
static uint32 *colmap;
|
static uint32 *colmap;
|
||||||
|
|
||||||
#define TRANSLATE(col) ( owncolmap ? col : colmap[col] )
|
#define TRANSLATE(col) ( owncolmap ? col : translate_colour(colmap[col]) )
|
||||||
#define SET_FOREGROUND(col) XSetForeground(display, gc, TRANSLATE(col));
|
#define SET_FOREGROUND(col) XSetForeground(display, gc, TRANSLATE(col));
|
||||||
#define SET_BACKGROUND(col) XSetBackground(display, gc, TRANSLATE(col));
|
#define SET_BACKGROUND(col) XSetBackground(display, gc, TRANSLATE(col));
|
||||||
|
|
||||||
@ -90,7 +98,7 @@ translate16(uint8 *data, uint16 *out, uint16 *end)
|
|||||||
*(out++) = (uint16)colmap[*(data++)];
|
*(out++) = (uint16)colmap[*(data++)];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX endianness */
|
/* little endian - conversion happens when colourmap is built */
|
||||||
static void
|
static void
|
||||||
translate24(uint8 *data, uint8 *out, uint8 *end)
|
translate24(uint8 *data, uint8 *out, uint8 *end)
|
||||||
{
|
{
|
||||||
@ -113,7 +121,7 @@ translate32(uint8 *data, uint32 *out, uint32 *end)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static uint8 *
|
static uint8 *
|
||||||
translate(int width, int height, uint8 *data)
|
translate_image(int width, int height, uint8 *data)
|
||||||
{
|
{
|
||||||
int size = width * height * bpp/8;
|
int size = width * height * bpp/8;
|
||||||
uint8 *out = xmalloc(size);
|
uint8 *out = xmalloc(size);
|
||||||
@ -141,9 +149,34 @@ translate(int width, int height, uint8 *data)
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define L_ENDIAN
|
#define BSWAP16(x) x = (((x & 0xff) << 8) | (x >> 8));
|
||||||
int screen_msbfirst = 0;
|
#define BSWAP24(x) x = (((x & 0xff) << 16) | (x >> 16) | ((x >> 8) & 0xff00));
|
||||||
|
#define BSWAP32(x) x = (((x & 0xff00ff) << 8) | ((x >> 8) & 0xff00ff)); \
|
||||||
|
x = (x << 16) | (x >> 16);
|
||||||
|
|
||||||
|
static uint32
|
||||||
|
translate_colour(uint32 colour)
|
||||||
|
{
|
||||||
|
switch (bpp)
|
||||||
|
{
|
||||||
|
case 16:
|
||||||
|
if (host_be != xserver_be)
|
||||||
|
BSWAP16(colour);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 24:
|
||||||
|
if (xserver_be)
|
||||||
|
BSWAP24(colour);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 32:
|
||||||
|
if (host_be != xserver_be)
|
||||||
|
BSWAP32(colour);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return colour;
|
||||||
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
ui_create_window(char *title)
|
ui_create_window(char *title)
|
||||||
@ -154,9 +187,9 @@ ui_create_window(char *title)
|
|||||||
unsigned long input_mask;
|
unsigned long input_mask;
|
||||||
XPixmapFormatValues *pfm;
|
XPixmapFormatValues *pfm;
|
||||||
Screen *screen;
|
Screen *screen;
|
||||||
|
uint16 test;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
||||||
display = XOpenDisplay(NULL);
|
display = XOpenDisplay(NULL);
|
||||||
if (display == NULL)
|
if (display == NULL)
|
||||||
{
|
{
|
||||||
@ -164,6 +197,7 @@ ui_create_window(char *title)
|
|||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
x_socket = ConnectionNumber(display);
|
||||||
screen = DefaultScreenOfDisplay(display);
|
screen = DefaultScreenOfDisplay(display);
|
||||||
visual = DefaultVisualOfScreen(screen);
|
visual = DefaultVisualOfScreen(screen);
|
||||||
depth = DefaultDepthOfScreen(screen);
|
depth = DefaultDepthOfScreen(screen);
|
||||||
@ -196,6 +230,10 @@ ui_create_window(char *title)
|
|||||||
else
|
else
|
||||||
xcolmap = DefaultColormapOfScreen(screen);
|
xcolmap = DefaultColormapOfScreen(screen);
|
||||||
|
|
||||||
|
test = 1;
|
||||||
|
host_be = !(BOOL)(*(uint8 *)(&test));
|
||||||
|
xserver_be = (ImageByteOrder(display) == MSBFirst);
|
||||||
|
|
||||||
white = WhitePixelOfScreen(screen);
|
white = WhitePixelOfScreen(screen);
|
||||||
attribs.background_pixel = BlackPixelOfScreen(screen);
|
attribs.background_pixel = BlackPixelOfScreen(screen);
|
||||||
attribs.backing_store = DoesBackingStore(screen);
|
attribs.backing_store = DoesBackingStore(screen);
|
||||||
@ -343,8 +381,8 @@ xwin_translate_mouse(unsigned long button)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
ui_process_events()
|
xwin_process_events()
|
||||||
{
|
{
|
||||||
XEvent event;
|
XEvent event;
|
||||||
uint8 scancode;
|
uint8 scancode;
|
||||||
@ -427,6 +465,39 @@ ui_process_events()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ui_select(int rdp_socket)
|
||||||
|
{
|
||||||
|
int n = (rdp_socket > x_socket) ? rdp_socket+1 : x_socket+1;
|
||||||
|
fd_set rfds;
|
||||||
|
|
||||||
|
XFlush(display);
|
||||||
|
|
||||||
|
FD_ZERO(&rfds);
|
||||||
|
|
||||||
|
while (True)
|
||||||
|
{
|
||||||
|
FD_ZERO(&rfds);
|
||||||
|
FD_SET(rdp_socket, &rfds);
|
||||||
|
FD_SET(x_socket, &rfds);
|
||||||
|
|
||||||
|
switch (select(n, &rfds, NULL, NULL, NULL))
|
||||||
|
{
|
||||||
|
case -1:
|
||||||
|
error("select: %s\n", strerror(errno));
|
||||||
|
|
||||||
|
case 0:
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FD_ISSET(x_socket, &rfds))
|
||||||
|
xwin_process_events();
|
||||||
|
|
||||||
|
if (FD_ISSET(rdp_socket, &rfds))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ui_move_pointer(int x, int y)
|
ui_move_pointer(int x, int y)
|
||||||
{
|
{
|
||||||
@ -440,7 +511,7 @@ ui_create_bitmap(int width, int height, uint8 *data)
|
|||||||
Pixmap bitmap;
|
Pixmap bitmap;
|
||||||
uint8 *tdata;
|
uint8 *tdata;
|
||||||
|
|
||||||
tdata = (owncolmap ? data : translate(width, height, data));
|
tdata = (owncolmap ? data : translate_image(width, height, data));
|
||||||
bitmap = XCreatePixmap(display, wnd, width, height, depth);
|
bitmap = XCreatePixmap(display, wnd, width, height, depth);
|
||||||
image = XCreateImage(display, visual, depth, ZPixmap,
|
image = XCreateImage(display, visual, depth, ZPixmap,
|
||||||
0, tdata, width, height, 8, 0);
|
0, tdata, width, height, 8, 0);
|
||||||
@ -460,7 +531,7 @@ ui_paint_bitmap(int x, int y, int cx, int cy,
|
|||||||
XImage *image;
|
XImage *image;
|
||||||
uint8 *tdata;
|
uint8 *tdata;
|
||||||
|
|
||||||
tdata = (owncolmap ? data : translate(width, height, data));
|
tdata = (owncolmap ? data : translate_image(width, height, data));
|
||||||
image = XCreateImage(display, visual, depth, ZPixmap,
|
image = XCreateImage(display, visual, depth, ZPixmap,
|
||||||
0, tdata, width, height, 8, 0);
|
0, tdata, width, height, 8, 0);
|
||||||
|
|
||||||
@ -635,6 +706,7 @@ ui_create_colourmap(COLOURMAP *colours)
|
|||||||
{
|
{
|
||||||
uint32 *map = xmalloc(sizeof(*colmap) * ncolours);
|
uint32 *map = xmalloc(sizeof(*colmap) * ncolours);
|
||||||
XColor xentry;
|
XColor xentry;
|
||||||
|
uint32 colour;
|
||||||
|
|
||||||
for (i = 0; i < ncolours; i++)
|
for (i = 0; i < ncolours; i++)
|
||||||
{
|
{
|
||||||
@ -642,9 +714,12 @@ ui_create_colourmap(COLOURMAP *colours)
|
|||||||
MAKE_XCOLOR(&xentry, entry);
|
MAKE_XCOLOR(&xentry, entry);
|
||||||
|
|
||||||
if (XAllocColor(display, xcolmap, &xentry) != 0)
|
if (XAllocColor(display, xcolmap, &xentry) != 0)
|
||||||
map[i] = xentry.pixel;
|
colour = translate_colour(xentry.pixel);
|
||||||
else
|
else
|
||||||
map[i] = white;
|
colour = translate_colour(white);
|
||||||
|
|
||||||
|
/* byte swap here to make translate_image faster */
|
||||||
|
map[i] = translate_colour(colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
|
Loading…
Reference in New Issue
Block a user