20 |
|
|
21 |
#include <X11/Xlib.h> |
#include <X11/Xlib.h> |
22 |
#include <X11/Xutil.h> |
#include <X11/Xutil.h> |
23 |
|
#include <unistd.h> |
24 |
#include <time.h> |
#include <time.h> |
25 |
#include <errno.h> |
#include <errno.h> |
26 |
#include "rdesktop.h" |
#include "rdesktop.h" |
208 |
} |
} |
209 |
|
|
210 |
#define BSWAP16(x) { x = (((x & 0xff) << 8) | (x >> 8)); } |
#define BSWAP16(x) { x = (((x & 0xff) << 8) | (x >> 8)); } |
211 |
#define BSWAP24(x) { x = (((x & 0xff) << 16) | (x >> 16) | ((x >> 8) & 0xff00)); } |
#define BSWAP24(x) { x = (((x & 0xff) << 16) | (x >> 16) | (x & 0xff00)); } |
212 |
#define BSWAP32(x) { x = (((x & 0xff00ff) << 8) | ((x >> 8) & 0xff00ff)); \ |
#define BSWAP32(x) { x = (((x & 0xff00ff) << 8) | ((x >> 8) & 0xff00ff)); \ |
213 |
x = (x << 16) | (x >> 16); } |
x = (x << 16) | (x >> 16); } |
214 |
|
|
246 |
while (out < end) |
while (out < end) |
247 |
{ |
{ |
248 |
value = (uint16) g_colmap[*(data++)]; |
value = (uint16) g_colmap[*(data++)]; |
249 |
|
|
250 |
if (g_xserver_be) |
if (g_xserver_be) |
251 |
{ |
{ |
252 |
*(out++) = value >> 8; |
*(out++) = value >> 8; |
269 |
while (out < end) |
while (out < end) |
270 |
{ |
{ |
271 |
value = g_colmap[*(data++)]; |
value = g_colmap[*(data++)]; |
272 |
|
|
273 |
if (g_xserver_be) |
if (g_xserver_be) |
274 |
{ |
{ |
275 |
*(out++) = value >> 16; |
*(out++) = value >> 16; |
409 |
} |
} |
410 |
|
|
411 |
static void |
static void |
412 |
translate16to16(uint16 * data, uint16 * out, uint16 * end) |
translate16to16(uint16 * data, uint8 * out, uint8 * end) |
413 |
{ |
{ |
414 |
|
uint16 pixel; |
415 |
uint16 value; |
uint16 value; |
416 |
|
|
417 |
if (g_xserver_be) |
while (out < end) |
418 |
{ |
{ |
419 |
while (out < end) |
pixel = *(data++); |
420 |
|
|
421 |
|
if (g_host_be) |
422 |
{ |
{ |
423 |
value = *data; |
BSWAP16(pixel); |
|
BSWAP16(value); |
|
|
*out = value; |
|
|
data++; |
|
|
out++; |
|
424 |
} |
} |
425 |
|
|
426 |
} |
value = make_colour(split_colour16(pixel)); |
427 |
else |
|
428 |
{ |
if (g_xserver_be) |
429 |
while (out < end) |
{ |
430 |
|
*(out++) = value >> 8; |
431 |
|
*(out++) = value; |
432 |
|
} |
433 |
|
else |
434 |
{ |
{ |
435 |
*out = *data; |
*(out++) = value; |
436 |
out++; |
*(out++) = value >> 8; |
|
data++; |
|
437 |
} |
} |
438 |
} |
} |
439 |
} |
} |
440 |
|
|
|
|
|
441 |
static void |
static void |
442 |
translate16to24(uint16 * data, uint8 * out, uint8 * end) |
translate16to24(uint16 * data, uint8 * out, uint8 * end) |
443 |
{ |
{ |
482 |
|
|
483 |
if (g_host_be) |
if (g_host_be) |
484 |
{ |
{ |
485 |
BSWAP16(pixel)} |
BSWAP16(pixel); |
486 |
|
} |
487 |
|
|
488 |
value = make_colour(split_colour16(pixel)); |
value = make_colour(split_colour16(pixel)); |
489 |
|
|
533 |
static void |
static void |
534 |
translate24to24(uint8 * data, uint8 * out, uint8 * end) |
translate24to24(uint8 * data, uint8 * out, uint8 * end) |
535 |
{ |
{ |
536 |
|
uint32 pixel; |
537 |
|
uint32 value; |
538 |
|
|
539 |
while (out < end) |
while (out < end) |
540 |
{ |
{ |
541 |
*(out++) = (*(data++)); |
pixel = *(data++) << 16; |
542 |
|
pixel |= *(data++) << 8; |
543 |
|
pixel |= *(data++); |
544 |
|
|
545 |
|
value = make_colour(split_colour24(pixel)); |
546 |
|
|
547 |
|
if (g_xserver_be) |
548 |
|
{ |
549 |
|
*(out++) = value >> 16; |
550 |
|
*(out++) = value >> 8; |
551 |
|
*(out++) = value; |
552 |
|
} |
553 |
|
else |
554 |
|
{ |
555 |
|
*(out++) = value; |
556 |
|
*(out++) = value >> 8; |
557 |
|
*(out++) = value >> 16; |
558 |
|
} |
559 |
} |
} |
560 |
} |
} |
561 |
|
|
562 |
static void |
static void |
563 |
translate24to32(uint8 * data, uint8 * out, uint8 * end) |
translate24to32(uint8 * data, uint8 * out, uint8 * end) |
564 |
{ |
{ |
565 |
|
uint32 pixel; |
566 |
|
uint32 value; |
567 |
|
|
568 |
while (out < end) |
while (out < end) |
569 |
{ |
{ |
570 |
|
pixel = *(data++) << 16; |
571 |
|
pixel |= *(data++) << 8; |
572 |
|
pixel |= *(data++); |
573 |
|
|
574 |
|
value = make_colour(split_colour24(pixel)); |
575 |
|
|
576 |
if (g_xserver_be) |
if (g_xserver_be) |
577 |
{ |
{ |
578 |
*(out++) = 0x00; |
*(out++) = value >> 24; |
579 |
*(out++) = *(data++); |
*(out++) = value >> 16; |
580 |
*(out++) = *(data++); |
*(out++) = value >> 8; |
581 |
*(out++) = *(data++); |
*(out++) = value; |
582 |
} |
} |
583 |
else |
else |
584 |
{ |
{ |
585 |
*(out++) = *(data++); |
*(out++) = value; |
586 |
*(out++) = *(data++); |
*(out++) = value >> 8; |
587 |
*(out++) = *(data++); |
*(out++) = value >> 16; |
588 |
*(out++) = 0x00; |
*(out++) = value >> 24; |
589 |
} |
} |
590 |
} |
} |
591 |
} |
} |
623 |
translate16to24((uint16 *) data, out, end); |
translate16to24((uint16 *) data, out, end); |
624 |
break; |
break; |
625 |
case 16: |
case 16: |
626 |
translate16to16((uint16 *) data, (uint16 *) out, |
translate16to16((uint16 *) data, out, end); |
|
(uint16 *) end); |
|
627 |
break; |
break; |
628 |
} |
} |
629 |
break; |
break; |
731 |
|
|
732 |
g_visual = vi.visual; |
g_visual = vi.visual; |
733 |
g_owncolmap = False; |
g_owncolmap = False; |
734 |
calculate_shifts(vi.red_mask, &g_red_shift_r, &g_red_shift_l); |
calculate_shifts(vi.red_mask, &g_red_shift_r, &g_red_shift_l); |
735 |
calculate_shifts(vi.blue_mask, &g_blue_shift_r, &g_blue_shift_l); |
calculate_shifts(vi.blue_mask, &g_blue_shift_r, &g_blue_shift_l); |
736 |
calculate_shifts(vi.green_mask, &g_green_shift_r, &g_green_shift_l); |
calculate_shifts(vi.green_mask, &g_green_shift_r, &g_green_shift_l); |
737 |
} |
} |
738 |
|
|
850 |
g_display = NULL; |
g_display = NULL; |
851 |
} |
} |
852 |
|
|
|
#define NULL_POINTER_MASK "\x80" |
|
|
#define NULL_POINTER_DATA "\x0\x0\x0" |
|
|
|
|
853 |
BOOL |
BOOL |
854 |
ui_create_window(void) |
ui_create_window(void) |
855 |
{ |
{ |
856 |
|
uint8 null_pointer_mask[1] = { 0x80 }; |
857 |
|
uint8 null_pointer_data[4] = { 0x00, 0x00, 0x00, 0x00 }; |
858 |
XSetWindowAttributes attribs; |
XSetWindowAttributes attribs; |
859 |
XClassHint *classhints; |
XClassHint *classhints; |
860 |
XSizeHints *sizehints; |
XSizeHints *sizehints; |
937 |
XSetWMProtocols(g_display, g_wnd, &g_kill_atom, 1); |
XSetWMProtocols(g_display, g_wnd, &g_kill_atom, 1); |
938 |
|
|
939 |
/* create invisible 1x1 cursor to be used as null cursor */ |
/* create invisible 1x1 cursor to be used as null cursor */ |
940 |
g_null_cursor = ui_create_cursor(0, 0, 1, 1, NULL_POINTER_MASK, NULL_POINTER_DATA); |
g_null_cursor = ui_create_cursor(0, 0, 1, 1, null_pointer_mask, null_pointer_data); |
941 |
|
|
942 |
return True; |
return True; |
943 |
} |
} |
945 |
void |
void |
946 |
ui_destroy_window(void) |
ui_destroy_window(void) |
947 |
{ |
{ |
|
ui_destroy_cursor(g_null_cursor); |
|
|
|
|
948 |
if (g_IC != NULL) |
if (g_IC != NULL) |
949 |
XDestroyIC(g_IC); |
XDestroyIC(g_IC); |
950 |
|
|