--- sourceforge.net/trunk/rdesktop/xwin.c 2003/10/05 12:07:56 478 +++ sourceforge.net/trunk/rdesktop/xwin.c 2003/10/22 10:55:11 508 @@ -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; @@ -51,7 +49,10 @@ static XIC g_IC; static XModifierKeymap *g_mod_map; static Cursor g_current_cursor; +static HCURSOR g_null_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; @@ -69,6 +70,7 @@ #ifdef WITH_RDPSND extern int g_dsp_fd; extern BOOL g_dsp_busy; +extern BOOL g_rdpsnd; #endif /* MWM decorations */ @@ -280,24 +282,6 @@ } break; } - switch (g_bpp) - { - case 16: - if (g_host_be != g_xserver_be) - BSWAP16(colour); - break; - - case 24: - if (g_xserver_be) - BSWAP24(colour); - break; - - case 32: - if (g_host_be != g_xserver_be) - BSWAP32(colour); - break; - } - return colour; } @@ -340,42 +324,94 @@ /* todo the remaining translate function might need some big endian check ?? */ static void -translate15to16(uint16 * data, uint16 * out, uint16 * end) +translate15to16(uint16 * data, uint8 * out, uint8 * end) { + uint16 pixel; + uint16 value; + while (out < end) - *(out++) = (uint16) make_colour16(split_colour15(*(data++))); + { + pixel = *(data++); + + if (g_host_be) + { + BSWAP16(pixel)} + + value = make_colour16(split_colour15(pixel)); + + if (g_xserver_be) + { + *(out++) = value >> 8; + *(out++) = value; + } + else + { + *(out++) = value; + *(out++) = value >> 8; + } + } } static void translate15to24(uint16 * data, uint8 * out, uint8 * end) { uint32 value; + uint16 pixel; while (out < end) { - value = make_colour24(split_colour15(*(data++))); - *(out++) = value; - *(out++) = value >> 8; - *(out++) = value >> 16; + pixel = *(data++); + + if (g_host_be) + { + BSWAP16(pixel)} + + value = make_colour24(split_colour15(pixel)); + if (g_xserver_be) + { + *(out++) = value >> 16; + *(out++) = value >> 8; + *(out++) = value; + } + else + { + *(out++) = value; + *(out++) = value >> 8; + *(out++) = value >> 16; + } } } static void -translate15to32(uint16 * data, uint32 * out, uint32 * end) +translate15to32(uint16 * data, uint8 * out, uint8 * end) { uint16 pixel; + uint32 value; while (out < end) { + pixel = *(data++); + if (g_host_be) { - pixel = *(data++); - pixel = (pixel & 0xff) << 8 | (pixel & 0xff00) >> 8; - *(out++) = make_colour32(split_colour15(pixel)); + BSWAP16(pixel); + } + + value = make_colour32(split_colour15(pixel)); + + if (g_xserver_be) + { + *(out++) = value >> 24; + *(out++) = value >> 16; + *(out++) = value >> 8; + *(out++) = value; } else { - *(out++) = make_colour32(split_colour15(*(data++))); + *(out++) = value; + *(out++) = value >> 8; + *(out++) = value >> 16; + *(out++) = value >> 24; } } } @@ -383,8 +419,29 @@ static void translate16to16(uint16 * data, uint16 * out, uint16 * end) { - while (out < end) - *(out++) = (uint16) (*(data++)); + uint16 value; + + if (g_xserver_be) + { + while (out < end) + { + value = *data; + BSWAP16(value); + *out = value; + data++; + out++; + } + + } + else + { + while (out < end) + { + *out = *data; + out++; + data++; + } + } } @@ -392,46 +449,89 @@ translate16to24(uint16 * data, uint8 * out, uint8 * end) { uint32 value; + uint16 pixel; while (out < end) { - value = make_colour24(split_colour16(*(data++))); - *(out++) = value; - *(out++) = value >> 8; - *(out++) = value >> 16; + pixel = *(data++); + + if (g_host_be) + { + BSWAP16(pixel)} + + value = make_colour24(split_colour16(pixel)); + + if (g_xserver_be) + { + *(out++) = value >> 16; + *(out++) = value >> 8; + *(out++) = value; + } + else + { + *(out++) = value; + *(out++) = value >> 8; + *(out++) = value >> 16; + } } } static void -translate16to32(uint16 * data, uint32 * out, uint32 * end) +translate16to32(uint16 * data, uint8 * out, uint8 * end) { uint16 pixel; + uint32 value; while (out < end) { + pixel = *(data++); + if (g_host_be) { - pixel = *(data++); - pixel = (pixel & 0xff) << 8 | (pixel & 0xff00) >> 8; - *(out++) = make_colour32(split_colour16(pixel)); + BSWAP16(pixel)} + + value = make_colour32(split_colour16(pixel)); + + if (g_xserver_be) + { + *(out++) = value >> 24; + *(out++) = value >> 16; + *(out++) = value >> 8; + *(out++) = value; } else { - *(out++) = make_colour32(split_colour16(*(data++))); + *(out++) = value; + *(out++) = value >> 8; + *(out++) = value >> 16; + *(out++) = value >> 24; } } } static void -translate24to16(uint8 * data, uint16 * out, uint16 * end) +translate24to16(uint8 * data, uint8 * out, uint8 * end) { uint32 pixel = 0; + uint16 value; while (out < end) { pixel = *(data++) << 16; pixel |= *(data++) << 8; pixel |= *(data++); - *(out++) = (uint16) make_colour16(split_colour24(pixel)); + + value = (uint16) make_colour16(split_colour24(pixel)); + + if (g_xserver_be) + { + *(out++) = value >> 8; + *(out++) = value; + } + else + { + *(out++) = value; + *(out++) = value >> 8; + } } } @@ -445,24 +545,24 @@ } static void -translate24to32(uint8 * data, uint32 * out, uint32 * end) +translate24to32(uint8 * data, uint8 * out, uint8 * end) { - uint32 pixel = 0; while (out < end) { - if (g_host_be) + if (g_xserver_be) { - pixel = *(data++) << 16; - pixel |= *(data++) << 8; - pixel |= *(data++); + *(out++) = 0x00; + *(out++) = *(data++); + *(out++) = *(data++); + *(out++) = *(data++); } else { - pixel = *(data++); - pixel |= *(data++) << 8; - pixel |= *(data++) << 16; + *(out++) = *(data++); + *(out++) = *(data++); + *(out++) = *(data++); + *(out++) = 0x00; } - *(out++) = pixel; } } @@ -479,13 +579,13 @@ switch (g_bpp) { case 32: - translate24to32(data, (uint32 *) out, (uint32 *) end); + translate24to32(data, out, end); break; case 24: translate24to24(data, out, end); break; case 16: - translate24to16(data, (uint16 *) out, (uint16 *) end); + translate24to16(data, out, end); break; } break; @@ -493,8 +593,7 @@ switch (g_bpp) { case 32: - translate16to32((uint16 *) data, (uint32 *) out, - (uint32 *) end); + translate16to32((uint16 *) data, out, end); break; case 24: translate16to24((uint16 *) data, out, end); @@ -509,15 +608,13 @@ switch (g_bpp) { case 32: - translate15to32((uint16 *) data, (uint32 *) out, - (uint32 *) end); + translate15to32((uint16 *) data, out, end); break; case 24: translate15to24((uint16 *) data, out, end); break; case 16: - translate15to16((uint16 *) data, (uint16 *) out, - (uint16 *) end); + translate15to16((uint16 *) data, out, end); break; } break; @@ -624,7 +721,16 @@ g_host_be = !(BOOL) (*(uint8 *) (&test)); g_xserver_be = (ImageByteOrder(g_display) == MSBFirst); - if ((g_width == 0) || (g_height == 0)) + /* + * Determine desktop size + */ + if (g_width < 0) + { + /* Percent of screen */ + g_height = HeightOfScreen(g_screen) * (-g_width) / 100; + g_width = WidthOfScreen(g_screen) * (-g_width) / 100; + } + else if (g_width == 0) { /* Fetch geometry from _NET_WORKAREA */ uint32 x, y, cx, cy; @@ -641,8 +747,7 @@ g_height = 600; } } - - if (g_fullscreen) + else if (g_fullscreen) { g_width = WidthOfScreen(g_screen); g_height = HeightOfScreen(g_screen); @@ -664,10 +769,11 @@ g_mod_map = XGetModifierMapping(g_display); + xkeymap_init(); + if (g_enable_compose) g_IM = XOpenIM(g_display, NULL, NULL, NULL); - xkeymap_init(); xclip_init(); /* todo take this out when high colour is done */ @@ -692,6 +798,9 @@ g_display = NULL; } +#define NULL_POINTER_MASK "\x80" +#define NULL_POINTER_DATA "\x0\x0\x0" + BOOL ui_create_window(void) { @@ -776,12 +885,17 @@ g_kill_atom = XInternAtom(g_display, "WM_DELETE_WINDOW", True); XSetWMProtocols(g_display, g_wnd, &g_kill_atom, 1); + /* create invisible 1x1 cursor to be used as null cursor */ + g_null_cursor = ui_create_cursor(0, 0, 1, 1, NULL_POINTER_MASK, NULL_POINTER_DATA); + return True; } void ui_destroy_window(void) { + ui_destroy_cursor(g_null_cursor); + if (g_IC != NULL) XDestroyIC(g_IC); @@ -1103,7 +1217,7 @@ { 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)) @@ -1297,6 +1411,12 @@ XFreeCursor(g_display, (Cursor) cursor); } +void +ui_set_null_cursor(void) +{ + ui_set_cursor(g_null_cursor); +} + #define MAKE_XCOLOR(xc,c) \ (xc)->red = ((c)->red << 8) | (c)->red; \ (xc)->green = ((c)->green << 8) | (c)->green; \ @@ -1497,8 +1617,8 @@ case 2: /* Hatch */ fill = (Pixmap) ui_create_glyph(8, 8, hatch_patterns + brush->pattern[0] * 8); - SET_FOREGROUND(bgcolour); - SET_BACKGROUND(fgcolour); + SET_FOREGROUND(fgcolour); + SET_BACKGROUND(bgcolour); XSetFillStyle(g_display, g_gc, FillOpaqueStippled); XSetStipple(g_display, g_gc, fill); XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);