Applied rdesktop-visual-host-be-fix.patch from #1390148, which fixes a problem when rdesktop is run on a machine with different byte order than the Xserver.

git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@1048 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
Peter Åstrand 2006-03-01 13:54:19 +00:00
parent ced8a62080
commit 265f5c101b

44
xwin.c
View File

@ -71,12 +71,23 @@ static HCURSOR g_null_cursor = NULL;
static Atom g_protocol_atom, g_kill_atom; static Atom g_protocol_atom, g_kill_atom;
static BOOL g_focused; static BOOL g_focused;
static BOOL g_mouse_in_wnd; static BOOL g_mouse_in_wnd;
/* Indicates the visual is has 15, 16 or 24 depth /* Indicates that:
and the same color channel masks as its RDP equivalent. */ 1) visual has 15, 16 or 24 depth and the same color channel masks
static BOOL g_compatible_depth; as its RDP equivalent (implies X server is LE),
2) host is LE
This will trigger an optimization whose real value is questionable.
*/
static BOOL g_compatible_arch;
/* Indicates whether RDP's bitmaps and our XImages have the same /* Indicates whether RDP's bitmaps and our XImages have the same
binary format. If so, we can avoid an expensive translation. binary format. If so, we can avoid an expensive translation.
If this is True, so is g_compatible_depth. */ Note that this can be true when g_compatible_arch is false,
e.g.:
RDP(LE) <-> host(BE) <-> X-Server(LE)
('host' is the machine running rdesktop; the host simply memcpy's
so its endianess doesn't matter)
*/
static BOOL g_no_translate_image = False; static BOOL g_no_translate_image = False;
/* endianness */ /* endianness */
@ -243,6 +254,9 @@ mwm_hide_decorations(void)
#define BSWAP32(x) { x = (((x & 0xff00ff) << 8) | ((x >> 8) & 0xff00ff)); \ #define BSWAP32(x) { x = (((x & 0xff00ff) << 8) | ((x >> 8) & 0xff00ff)); \
x = (x << 16) | (x >> 16); } x = (x << 16) | (x >> 16); }
/* The following macros output the same octet sequences
on both BE and LE hosts: */
#define BOUT16(o, x) { *(o++) = x >> 8; *(o++) = x; } #define BOUT16(o, x) { *(o++) = x >> 8; *(o++) = x; }
#define BOUT24(o, x) { *(o++) = x >> 16; *(o++) = x >> 8; *(o++) = x; } #define BOUT24(o, x) { *(o++) = x >> 16; *(o++) = x >> 8; *(o++) = x; }
#define BOUT32(o, x) { *(o++) = x >> 24; *(o++) = x >> 16; *(o++) = x >> 8; *(o++) = x; } #define BOUT32(o, x) { *(o++) = x >> 24; *(o++) = x >> 16; *(o++) = x >> 8; *(o++) = x; }
@ -322,7 +336,7 @@ translate8to16(const uint8 * data, uint8 * out, uint8 * end)
{ {
uint16 value; uint16 value;
if (g_compatible_depth) if (g_compatible_arch)
{ {
/* *INDENT-OFF* */ /* *INDENT-OFF* */
REPEAT2 REPEAT2
@ -356,7 +370,7 @@ translate8to24(const uint8 * data, uint8 * out, uint8 * end)
{ {
uint32 value; uint32 value;
if (g_compatible_depth) if (g_compatible_arch)
{ {
while (out < end) while (out < end)
{ {
@ -379,7 +393,7 @@ translate8to32(const uint8 * data, uint8 * out, uint8 * end)
{ {
uint32 value; uint32 value;
if (g_compatible_depth) if (g_compatible_arch)
{ {
/* *INDENT-OFF* */ /* *INDENT-OFF* */
REPEAT4 REPEAT4
@ -451,7 +465,7 @@ translate15to24(const uint16 * data, uint8 * out, uint8 * end)
uint16 pixel; uint16 pixel;
PixelColour pc; PixelColour pc;
if (g_compatible_depth) if (g_compatible_arch)
{ {
/* *INDENT-OFF* */ /* *INDENT-OFF* */
REPEAT3 REPEAT3
@ -501,7 +515,7 @@ translate15to32(const uint16 * data, uint8 * out, uint8 * end)
uint32 value; uint32 value;
PixelColour pc; PixelColour pc;
if (g_compatible_depth) if (g_compatible_arch)
{ {
/* *INDENT-OFF* */ /* *INDENT-OFF* */
REPEAT4 REPEAT4
@ -609,7 +623,7 @@ translate16to24(const uint16 * data, uint8 * out, uint8 * end)
uint16 pixel; uint16 pixel;
PixelColour pc; PixelColour pc;
if (g_compatible_depth) if (g_compatible_arch)
{ {
/* *INDENT-OFF* */ /* *INDENT-OFF* */
REPEAT3 REPEAT3
@ -679,7 +693,7 @@ translate16to32(const uint16 * data, uint8 * out, uint8 * end)
uint32 value; uint32 value;
PixelColour pc; PixelColour pc;
if (g_compatible_depth) if (g_compatible_arch)
{ {
/* *INDENT-OFF* */ /* *INDENT-OFF* */
REPEAT4 REPEAT4
@ -808,7 +822,7 @@ translate24to32(const uint8 * data, uint8 * out, uint8 * end)
uint32 value; uint32 value;
PixelColour pc; PixelColour pc;
if (g_compatible_depth) if (g_compatible_arch)
{ {
/* *INDENT-OFF* */ /* *INDENT-OFF* */
#ifdef NEED_ALIGN #ifdef NEED_ALIGN
@ -1021,7 +1035,7 @@ select_visual()
vmatches = XGetVisualInfo(g_display, VisualClassMask, &template, &visuals_count); vmatches = XGetVisualInfo(g_display, VisualClassMask, &template, &visuals_count);
g_visual = NULL; g_visual = NULL;
g_no_translate_image = False; g_no_translate_image = False;
g_compatible_depth = False; g_compatible_arch = False;
if (vmatches != NULL) if (vmatches != NULL)
{ {
for (i = 0; i < visuals_count; ++i) for (i = 0; i < visuals_count; ++i)
@ -1048,7 +1062,7 @@ select_visual()
{ {
g_visual = visual_info->visual; g_visual = visual_info->visual;
g_depth = visual_info->depth; g_depth = visual_info->depth;
g_compatible_depth = True; g_compatible_arch = !g_host_be;
g_no_translate_image = (visual_info->depth == g_server_depth); g_no_translate_image = (visual_info->depth == g_server_depth);
if (g_no_translate_image) if (g_no_translate_image)
/* We found the best visual */ /* We found the best visual */
@ -1056,7 +1070,7 @@ select_visual()
} }
else else
{ {
g_compatible_depth = False; g_compatible_arch = False;
} }
if (visual_info->depth > 24) if (visual_info->depth > 24)