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
|
||||
|
||||
clean:
|
||||
rm -f *.o crypto/*.o *~
|
||||
rm -f *.o crypto/*.o *~ rdesktop
|
||||
|
||||
.SUFFIXES:
|
||||
.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);
|
||||
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);
|
||||
int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, BIGNUM *p,
|
||||
BIGNUM *m,BN_CTX *ctx);
|
||||
int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m,BN_CTX *ctx);
|
||||
int BN_mask_bits(BIGNUM *a,int n);
|
||||
int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
|
||||
#ifndef NO_FP_API
|
||||
|
@ -795,7 +795,7 @@ err:
|
||||
#endif
|
||||
|
||||
/* 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)
|
||||
{
|
||||
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);
|
||||
if (s == NULL)
|
||||
return False;
|
||||
return NULL;
|
||||
|
||||
in_uint8(s, version);
|
||||
if (version != 3)
|
||||
{
|
||||
error("TPKT v%d\n", version);
|
||||
return False;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
in_uint8s(s, 1); /* pad */
|
||||
@ -66,7 +66,7 @@ iso_recv_msg(uint8 *code)
|
||||
|
||||
s = tcp_recv(length - 4);
|
||||
if (s == NULL)
|
||||
return False;
|
||||
return NULL;
|
||||
|
||||
in_uint8s(s, 1); /* hdrlen */
|
||||
in_uint8(s, *code);
|
||||
@ -121,10 +121,13 @@ iso_recv()
|
||||
uint8 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);
|
||||
return False;
|
||||
error("expected DT, got 0x%x\n", code);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return s;
|
||||
@ -141,9 +144,12 @@ iso_connect(char *server)
|
||||
|
||||
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();
|
||||
return False;
|
||||
}
|
||||
|
2
proto.h
2
proto.h
@ -63,7 +63,7 @@ void tcp_disconnect(void);
|
||||
/* xwin.c */
|
||||
BOOL ui_create_window(char *title);
|
||||
void ui_destroy_window(void);
|
||||
void ui_process_events(void);
|
||||
void ui_select(int rdp_socket);
|
||||
void ui_move_pointer(int x, int y);
|
||||
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);
|
||||
|
@ -224,6 +224,7 @@ main(int argc, char *argv[])
|
||||
|
||||
printf("Connection successful.\n");
|
||||
rdp_main_loop();
|
||||
printf("Disconnecting...\n");
|
||||
ui_destroy_window();
|
||||
}
|
||||
|
||||
|
36
tcp.c
36
tcp.c
@ -56,11 +56,10 @@ tcp_send(STREAM s)
|
||||
|
||||
while (total < length)
|
||||
{
|
||||
sent = write(sock, s->data + total, length - total);
|
||||
|
||||
sent = send(sock, s->data + total, length - total, 0);
|
||||
if (sent <= 0)
|
||||
{
|
||||
error("write: %s\n", strerror(errno));
|
||||
error("send: %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -72,9 +71,7 @@ tcp_send(STREAM s)
|
||||
STREAM
|
||||
tcp_recv(int length)
|
||||
{
|
||||
int ret, rcvd = 0;
|
||||
struct timeval tv;
|
||||
fd_set rfds;
|
||||
int rcvd = 0;
|
||||
|
||||
if (length > in.size)
|
||||
{
|
||||
@ -86,28 +83,17 @@ tcp_recv(int length)
|
||||
|
||||
while (length > 0)
|
||||
{
|
||||
ui_process_events();
|
||||
ui_select(sock);
|
||||
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(sock, &rfds);
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 100;
|
||||
|
||||
ret = select(sock + 1, &rfds, NULL, NULL, &tv);
|
||||
|
||||
if (ret)
|
||||
rcvd = recv(sock, in.end, length, 0);
|
||||
if (rcvd == -1)
|
||||
{
|
||||
rcvd = read(sock, in.end, length);
|
||||
|
||||
if (rcvd <= 0)
|
||||
{
|
||||
error("read: %s\n", strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
in.end += rcvd;
|
||||
length -= rcvd;
|
||||
error("recv: %s\n", strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
in.end += rcvd;
|
||||
length -= rcvd;
|
||||
}
|
||||
|
||||
return ∈
|
||||
|
99
xwin.c
99
xwin.c
@ -21,6 +21,7 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include "rdesktop.h"
|
||||
|
||||
extern int width;
|
||||
@ -29,12 +30,18 @@ extern BOOL sendmotion;
|
||||
extern BOOL fullscreen;
|
||||
|
||||
static Display *display;
|
||||
static int x_socket;
|
||||
static Window wnd;
|
||||
static GC gc;
|
||||
static Visual *visual;
|
||||
static int depth;
|
||||
static int bpp;
|
||||
|
||||
/* endianness */
|
||||
static BOOL host_be;
|
||||
static BOOL xserver_be;
|
||||
|
||||
/* software backing store */
|
||||
static BOOL ownbackstore;
|
||||
static Pixmap backstore;
|
||||
|
||||
@ -45,12 +52,13 @@ static Pixmap backstore;
|
||||
XFillRectangle(display, backstore, gc, x, y, cx, cy); \
|
||||
}
|
||||
|
||||
/* colour maps */
|
||||
static BOOL owncolmap;
|
||||
static Colormap xcolmap;
|
||||
static uint32 white;
|
||||
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_BACKGROUND(col) XSetBackground(display, gc, TRANSLATE(col));
|
||||
|
||||
@ -90,7 +98,7 @@ translate16(uint8 *data, uint16 *out, uint16 *end)
|
||||
*(out++) = (uint16)colmap[*(data++)];
|
||||
}
|
||||
|
||||
/* XXX endianness */
|
||||
/* little endian - conversion happens when colourmap is built */
|
||||
static void
|
||||
translate24(uint8 *data, uint8 *out, uint8 *end)
|
||||
{
|
||||
@ -113,7 +121,7 @@ translate32(uint8 *data, uint32 *out, uint32 *end)
|
||||
}
|
||||
|
||||
static uint8 *
|
||||
translate(int width, int height, uint8 *data)
|
||||
translate_image(int width, int height, uint8 *data)
|
||||
{
|
||||
int size = width * height * bpp/8;
|
||||
uint8 *out = xmalloc(size);
|
||||
@ -141,9 +149,34 @@ translate(int width, int height, uint8 *data)
|
||||
return out;
|
||||
}
|
||||
|
||||
#define L_ENDIAN
|
||||
int screen_msbfirst = 0;
|
||||
#define BSWAP16(x) x = (((x & 0xff) << 8) | (x >> 8));
|
||||
#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
|
||||
ui_create_window(char *title)
|
||||
@ -154,9 +187,9 @@ ui_create_window(char *title)
|
||||
unsigned long input_mask;
|
||||
XPixmapFormatValues *pfm;
|
||||
Screen *screen;
|
||||
uint16 test;
|
||||
int i;
|
||||
|
||||
|
||||
display = XOpenDisplay(NULL);
|
||||
if (display == NULL)
|
||||
{
|
||||
@ -164,6 +197,7 @@ ui_create_window(char *title)
|
||||
return False;
|
||||
}
|
||||
|
||||
x_socket = ConnectionNumber(display);
|
||||
screen = DefaultScreenOfDisplay(display);
|
||||
visual = DefaultVisualOfScreen(screen);
|
||||
depth = DefaultDepthOfScreen(screen);
|
||||
@ -196,6 +230,10 @@ ui_create_window(char *title)
|
||||
else
|
||||
xcolmap = DefaultColormapOfScreen(screen);
|
||||
|
||||
test = 1;
|
||||
host_be = !(BOOL)(*(uint8 *)(&test));
|
||||
xserver_be = (ImageByteOrder(display) == MSBFirst);
|
||||
|
||||
white = WhitePixelOfScreen(screen);
|
||||
attribs.background_pixel = BlackPixelOfScreen(screen);
|
||||
attribs.backing_store = DoesBackingStore(screen);
|
||||
@ -343,8 +381,8 @@ xwin_translate_mouse(unsigned long button)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
ui_process_events()
|
||||
static void
|
||||
xwin_process_events()
|
||||
{
|
||||
XEvent event;
|
||||
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
|
||||
ui_move_pointer(int x, int y)
|
||||
{
|
||||
@ -440,7 +511,7 @@ ui_create_bitmap(int width, int height, uint8 *data)
|
||||
Pixmap bitmap;
|
||||
uint8 *tdata;
|
||||
|
||||
tdata = (owncolmap ? data : translate(width, height, data));
|
||||
tdata = (owncolmap ? data : translate_image(width, height, data));
|
||||
bitmap = XCreatePixmap(display, wnd, width, height, depth);
|
||||
image = XCreateImage(display, visual, depth, ZPixmap,
|
||||
0, tdata, width, height, 8, 0);
|
||||
@ -460,7 +531,7 @@ ui_paint_bitmap(int x, int y, int cx, int cy,
|
||||
XImage *image;
|
||||
uint8 *tdata;
|
||||
|
||||
tdata = (owncolmap ? data : translate(width, height, data));
|
||||
tdata = (owncolmap ? data : translate_image(width, height, data));
|
||||
image = XCreateImage(display, visual, depth, ZPixmap,
|
||||
0, tdata, width, height, 8, 0);
|
||||
|
||||
@ -635,6 +706,7 @@ ui_create_colourmap(COLOURMAP *colours)
|
||||
{
|
||||
uint32 *map = xmalloc(sizeof(*colmap) * ncolours);
|
||||
XColor xentry;
|
||||
uint32 colour;
|
||||
|
||||
for (i = 0; i < ncolours; i++)
|
||||
{
|
||||
@ -642,9 +714,12 @@ ui_create_colourmap(COLOURMAP *colours)
|
||||
MAKE_XCOLOR(&xentry, entry);
|
||||
|
||||
if (XAllocColor(display, xcolmap, &xentry) != 0)
|
||||
map[i] = xentry.pixel;
|
||||
colour = translate_colour(xentry.pixel);
|
||||
else
|
||||
map[i] = white;
|
||||
colour = translate_colour(white);
|
||||
|
||||
/* byte swap here to make translate_image faster */
|
||||
map[i] = translate_colour(colour);
|
||||
}
|
||||
|
||||
return map;
|
||||
|
Loading…
Reference in New Issue
Block a user