--- sourceforge.net/trunk/rdesktop/xwin.c 2003/09/02 09:40:07 461 +++ sourceforge.net/trunk/rdesktop/xwin.c 2003/10/09 03:28:04 481 @@ -34,15 +34,13 @@ extern char g_title[]; extern int g_server_bpp; extern int g_win_button_size; -BOOL g_enable_compose = False; -BOOL g_focused; -BOOL g_mouse_in_wnd; Display *g_display; Time g_last_gesturetime; static int g_x_socket; static Screen *g_screen; Window g_wnd; +BOOL g_enable_compose = False; static GC g_gc; static Visual *g_visual; static int g_depth; @@ -52,6 +50,8 @@ static XModifierKeymap *g_mod_map; static Cursor g_current_cursor; static Atom g_protocol_atom, g_kill_atom; +static BOOL g_focused; +static BOOL g_mouse_in_wnd; /* endianness */ static BOOL g_host_be; @@ -66,6 +66,11 @@ static int g_move_x_offset = 0; static int g_move_y_offset = 0; +#ifdef WITH_RDPSND +extern int g_dsp_fd; +extern BOOL g_dsp_busy; +#endif + /* MWM decorations */ #define MWM_HINTS_DECORATIONS (1L << 1) #define PROP_MOTIF_WM_HINTS_ELEMENTS 5 @@ -201,13 +206,27 @@ static uint32 make_colour24(PixelColour pc) { - return (pc.red << 16) | (pc.green << 8) | pc.blue; + if (g_xserver_be) + { + return pc.red | (pc.green << 8) | (pc.blue << 16); + } + else + { + return (pc.red << 16) | (pc.green << 8) | pc.blue; + } } static uint32 make_colour32(PixelColour pc) { - return (pc.red << 16) | (pc.green << 8) | pc.blue; + if (g_xserver_be) + { + return pc.red | (pc.green << 8) | (pc.blue << 16); + } + else + { + return (pc.red << 16) | (pc.green << 8) | pc.blue; + } } #define BSWAP16(x) { x = (((x & 0xff) << 8) | (x >> 8)); } @@ -344,8 +363,21 @@ static void translate15to32(uint16 * data, uint32 * out, uint32 * end) { + uint16 pixel; + while (out < end) - *(out++) = make_colour32(split_colour15(*(data++))); + { + if (g_host_be) + { + pixel = *(data++); + pixel = (pixel & 0xff) << 8 | (pixel & 0xff00) >> 8; + *(out++) = make_colour32(split_colour15(pixel)); + } + else + { + *(out++) = make_colour32(split_colour15(*(data++))); + } + } } static void @@ -373,8 +405,21 @@ static void translate16to32(uint16 * data, uint32 * out, uint32 * end) { + uint16 pixel; + while (out < end) - *(out++) = make_colour32(split_colour16(*(data++))); + { + if (g_host_be) + { + pixel = *(data++); + pixel = (pixel & 0xff) << 8 | (pixel & 0xff00) >> 8; + *(out++) = make_colour32(split_colour16(pixel)); + } + else + { + *(out++) = make_colour32(split_colour16(*(data++))); + } + } } static void @@ -405,9 +450,18 @@ uint32 pixel = 0; while (out < end) { - pixel = *(data++); - pixel |= *(data++) << 8; - pixel |= *(data++) << 16; + if (g_host_be) + { + pixel = *(data++) << 16; + pixel |= *(data++) << 8; + pixel |= *(data++); + } + else + { + pixel = *(data++); + pixel |= *(data++) << 8; + pixel |= *(data++) << 16; + } *(out++) = pixel; } } @@ -833,10 +887,10 @@ if (tr.scancode == 0) break; - save_remote_modifiers(); + save_remote_modifiers(tr.scancode); ensure_remote_modifiers(ev_time, tr); rdp_send_scancode(ev_time, RDP_KEYPRESS, tr.scancode); - restore_remote_modifiers(ev_time); + restore_remote_modifiers(ev_time, tr.scancode); break; @@ -1029,9 +1083,7 @@ ui_select(int rdp_socket) { int n = (rdp_socket > g_x_socket) ? rdp_socket + 1 : g_x_socket + 1; - fd_set rfds; - - FD_ZERO(&rfds); + fd_set rfds, wfds; while (True) { @@ -1041,10 +1093,20 @@ return 0; FD_ZERO(&rfds); + FD_ZERO(&wfds); FD_SET(rdp_socket, &rfds); FD_SET(g_x_socket, &rfds); - switch (select(n, &rfds, NULL, NULL, NULL)) +#ifdef WITH_RDPSND + /* FIXME: there should be an API for registering fds */ + if (g_dsp_busy) + { + FD_SET(g_dsp_fd, &wfds); + n = (g_dsp_fd + 1 > n) ? g_dsp_fd + 1 : n; + } +#endif + + switch (select(n, &rfds, &wfds, NULL, NULL)) { case -1: error("select: %s\n", strerror(errno)); @@ -1055,6 +1117,11 @@ if (FD_ISSET(rdp_socket, &rfds)) return 1; + +#ifdef WITH_RDPSND + if (g_dsp_busy && FD_ISSET(g_dsp_fd, &wfds)) + wave_out_play(); +#endif } }