34 |
extern char g_title[]; |
extern char g_title[]; |
35 |
extern int g_server_bpp; |
extern int g_server_bpp; |
36 |
extern int g_win_button_size; |
extern int g_win_button_size; |
|
BOOL g_enable_compose = False; |
|
|
BOOL g_focused; |
|
|
BOOL g_mouse_in_wnd; |
|
37 |
|
|
38 |
Display *g_display; |
Display *g_display; |
39 |
Time g_last_gesturetime; |
Time g_last_gesturetime; |
40 |
static int g_x_socket; |
static int g_x_socket; |
41 |
static Screen *g_screen; |
static Screen *g_screen; |
42 |
Window g_wnd; |
Window g_wnd; |
43 |
|
BOOL g_enable_compose = False; |
44 |
static GC g_gc; |
static GC g_gc; |
45 |
static Visual *g_visual; |
static Visual *g_visual; |
46 |
static int g_depth; |
static int g_depth; |
50 |
static XModifierKeymap *g_mod_map; |
static XModifierKeymap *g_mod_map; |
51 |
static Cursor g_current_cursor; |
static Cursor g_current_cursor; |
52 |
static Atom g_protocol_atom, g_kill_atom; |
static Atom g_protocol_atom, g_kill_atom; |
53 |
|
static BOOL g_focused; |
54 |
|
static BOOL g_mouse_in_wnd; |
55 |
|
|
56 |
/* endianness */ |
/* endianness */ |
57 |
static BOOL g_host_be; |
static BOOL g_host_be; |
280 |
} |
} |
281 |
break; |
break; |
282 |
} |
} |
|
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; |
|
|
} |
|
|
|
|
283 |
return colour; |
return colour; |
284 |
} |
} |
285 |
|
|
322 |
/* todo the remaining translate function might need some big endian check ?? */ |
/* todo the remaining translate function might need some big endian check ?? */ |
323 |
|
|
324 |
static void |
static void |
325 |
translate15to16(uint16 * data, uint16 * out, uint16 * end) |
translate15to16(uint16 * data, uint8 * out, uint8 * end) |
326 |
{ |
{ |
327 |
|
uint16 pixel; |
328 |
|
uint16 value; |
329 |
|
|
330 |
while (out < end) |
while (out < end) |
331 |
*(out++) = (uint16) make_colour16(split_colour15(*(data++))); |
{ |
332 |
|
pixel = *(data++); |
333 |
|
|
334 |
|
if (g_host_be) |
335 |
|
{ |
336 |
|
BSWAP16(pixel) |
337 |
|
} |
338 |
|
|
339 |
|
value = make_colour16(split_colour15(pixel)); |
340 |
|
|
341 |
|
if (g_xserver_be) |
342 |
|
{ |
343 |
|
*(out++) = value >> 8; |
344 |
|
*(out++) = value; |
345 |
|
} |
346 |
|
else |
347 |
|
{ |
348 |
|
*(out++) = value; |
349 |
|
*(out++) = value >> 8; |
350 |
|
} |
351 |
|
} |
352 |
} |
} |
353 |
|
|
354 |
static void |
static void |
355 |
translate15to24(uint16 * data, uint8 * out, uint8 * end) |
translate15to24(uint16 * data, uint8 * out, uint8 * end) |
356 |
{ |
{ |
357 |
uint32 value; |
uint32 value; |
358 |
|
uint16 pixel; |
359 |
|
|
360 |
while (out < end) |
while (out < end) |
361 |
{ |
{ |
362 |
value = make_colour24(split_colour15(*(data++))); |
pixel = *(data++); |
363 |
*(out++) = value; |
|
364 |
*(out++) = value >> 8; |
if (g_host_be) |
365 |
*(out++) = value >> 16; |
{ |
366 |
|
BSWAP16(pixel) |
367 |
|
} |
368 |
|
|
369 |
|
value = make_colour24(split_colour15(pixel)); |
370 |
|
if (g_xserver_be) |
371 |
|
{ |
372 |
|
*(out++) = value >> 16; |
373 |
|
*(out++) = value >> 8; |
374 |
|
*(out++) = value; |
375 |
|
} |
376 |
|
else |
377 |
|
{ |
378 |
|
*(out++) = value; |
379 |
|
*(out++) = value >> 8; |
380 |
|
*(out++) = value >> 16; |
381 |
|
} |
382 |
} |
} |
383 |
} |
} |
384 |
|
|
385 |
static void |
static void |
386 |
translate15to32(uint16 * data, uint32 * out, uint32 * end) |
translate15to32(uint16 * data, uint8 * out, uint8 * end) |
387 |
{ |
{ |
388 |
uint16 pixel; |
uint16 pixel; |
389 |
|
uint32 value; |
390 |
|
|
391 |
while (out < end) |
while (out < end) |
392 |
{ |
{ |
393 |
|
pixel = *(data++); |
394 |
|
|
395 |
if (g_host_be) |
if (g_host_be) |
396 |
{ |
{ |
397 |
pixel = *(data++); |
BSWAP16(pixel); |
398 |
pixel = (pixel & 0xff) << 8 | (pixel & 0xff00) >> 8; |
} |
399 |
*(out++) = make_colour32(split_colour15(pixel)); |
|
400 |
|
value = make_colour32(split_colour15(pixel)); |
401 |
|
|
402 |
|
if (g_xserver_be) |
403 |
|
{ |
404 |
|
*(out++) = value >> 24; |
405 |
|
*(out++) = value >> 16; |
406 |
|
*(out++) = value >> 8; |
407 |
|
*(out++) = value; |
408 |
} |
} |
409 |
else |
else |
410 |
{ |
{ |
411 |
*(out++) = make_colour32(split_colour15(*(data++))); |
*(out++) = value; |
412 |
|
*(out++) = value >> 8; |
413 |
|
*(out++) = value >> 16; |
414 |
|
*(out++) = value >> 24; |
415 |
} |
} |
416 |
} |
} |
417 |
} |
} |
419 |
static void |
static void |
420 |
translate16to16(uint16 * data, uint16 * out, uint16 * end) |
translate16to16(uint16 * data, uint16 * out, uint16 * end) |
421 |
{ |
{ |
422 |
while (out < end) |
uint16 value; |
423 |
*(out++) = (uint16) (*(data++)); |
|
424 |
|
if (g_xserver_be) |
425 |
|
{ |
426 |
|
while (out < end) |
427 |
|
{ |
428 |
|
value = *data; |
429 |
|
BSWAP16(value); |
430 |
|
*out = value; |
431 |
|
data++; |
432 |
|
out++; |
433 |
|
} |
434 |
|
|
435 |
|
} |
436 |
|
else |
437 |
|
{ |
438 |
|
while (out < end) |
439 |
|
{ |
440 |
|
*out = *data; |
441 |
|
out++; |
442 |
|
data++; |
443 |
|
} |
444 |
|
} |
445 |
} |
} |
446 |
|
|
447 |
|
|
449 |
translate16to24(uint16 * data, uint8 * out, uint8 * end) |
translate16to24(uint16 * data, uint8 * out, uint8 * end) |
450 |
{ |
{ |
451 |
uint32 value; |
uint32 value; |
452 |
|
uint16 pixel; |
453 |
|
|
454 |
while (out < end) |
while (out < end) |
455 |
{ |
{ |
456 |
value = make_colour24(split_colour16(*(data++))); |
pixel = *(data++); |
457 |
*(out++) = value; |
|
458 |
*(out++) = value >> 8; |
if (g_host_be) |
459 |
*(out++) = value >> 16; |
{ |
460 |
|
BSWAP16(pixel) |
461 |
|
} |
462 |
|
|
463 |
|
value = make_colour24(split_colour16(pixel)); |
464 |
|
|
465 |
|
if (g_xserver_be) |
466 |
|
{ |
467 |
|
*(out++) = value >> 16; |
468 |
|
*(out++) = value >> 8; |
469 |
|
*(out++) = value; |
470 |
|
} |
471 |
|
else |
472 |
|
{ |
473 |
|
*(out++) = value; |
474 |
|
*(out++) = value >> 8; |
475 |
|
*(out++) = value >> 16; |
476 |
|
} |
477 |
} |
} |
478 |
} |
} |
479 |
|
|
480 |
static void |
static void |
481 |
translate16to32(uint16 * data, uint32 * out, uint32 * end) |
translate16to32(uint16 * data, uint8 * out, uint8 * end) |
482 |
{ |
{ |
483 |
uint16 pixel; |
uint16 pixel; |
484 |
|
uint32 value; |
485 |
|
|
486 |
while (out < end) |
while (out < end) |
487 |
{ |
{ |
488 |
|
pixel = *(data++); |
489 |
|
|
490 |
if (g_host_be) |
if (g_host_be) |
491 |
{ |
{ |
492 |
pixel = *(data++); |
BSWAP16(pixel) |
|
pixel = (pixel & 0xff) << 8 | (pixel & 0xff00) >> 8; |
|
|
*(out++) = make_colour32(split_colour16(pixel)); |
|
493 |
} |
} |
494 |
else |
|
495 |
|
value = make_colour32(split_colour16(pixel)); |
496 |
|
|
497 |
|
if (g_xserver_be) |
498 |
{ |
{ |
499 |
*(out++) = make_colour32(split_colour16(*(data++))); |
*(out++) = value >> 24; |
500 |
} |
*(out++) = value >> 16; |
501 |
} |
*(out++) = value >> 8; |
502 |
|
*(out++) = value; |
503 |
|
} |
504 |
|
else |
505 |
|
{ |
506 |
|
*(out++) = value; |
507 |
|
*(out++) = value >> 8; |
508 |
|
*(out++) = value >> 16; |
509 |
|
*(out++) = value >> 24; |
510 |
|
} |
511 |
|
} |
512 |
} |
} |
513 |
|
|
514 |
static void |
static void |
515 |
translate24to16(uint8 * data, uint16 * out, uint16 * end) |
translate24to16(uint8 * data, uint8 * out, uint8 * end) |
516 |
{ |
{ |
517 |
uint32 pixel = 0; |
uint32 pixel = 0; |
518 |
|
uint16 value; |
519 |
while (out < end) |
while (out < end) |
520 |
{ |
{ |
521 |
pixel = *(data++) << 16; |
pixel = *(data++) << 16; |
522 |
pixel |= *(data++) << 8; |
pixel |= *(data++) << 8; |
523 |
pixel |= *(data++); |
pixel |= *(data++); |
524 |
*(out++) = (uint16) make_colour16(split_colour24(pixel)); |
|
525 |
|
value = (uint16) make_colour16(split_colour24(pixel)); |
526 |
|
|
527 |
|
if (g_xserver_be) |
528 |
|
{ |
529 |
|
*(out++) = value >> 8; |
530 |
|
*(out++) = value; |
531 |
|
} |
532 |
|
else |
533 |
|
{ |
534 |
|
*(out++) = value; |
535 |
|
*(out++) = value >> 8; |
536 |
|
} |
537 |
} |
} |
538 |
} |
} |
539 |
|
|
547 |
} |
} |
548 |
|
|
549 |
static void |
static void |
550 |
translate24to32(uint8 * data, uint32 * out, uint32 * end) |
translate24to32(uint8 * data, uint8 * out, uint8 * end) |
551 |
{ |
{ |
|
uint32 pixel = 0; |
|
552 |
while (out < end) |
while (out < end) |
553 |
{ |
{ |
554 |
if (g_host_be) |
if (g_xserver_be) |
555 |
{ |
{ |
556 |
pixel = *(data++) << 16; |
*(out++) = 0x00; |
557 |
pixel |= *(data++) << 8; |
*(out++) = *(data++); |
558 |
pixel |= *(data++); |
*(out++) = *(data++); |
559 |
|
*(out++) = *(data++); |
560 |
} |
} |
561 |
else |
else |
562 |
{ |
{ |
563 |
pixel = *(data++); |
*(out++) = *(data++); |
564 |
pixel |= *(data++) << 8; |
*(out++) = *(data++); |
565 |
pixel |= *(data++) << 16; |
*(out++) = *(data++); |
566 |
|
*(out++) = 0x00; |
567 |
} |
} |
|
*(out++) = pixel; |
|
568 |
} |
} |
569 |
} |
} |
570 |
|
|
581 |
switch (g_bpp) |
switch (g_bpp) |
582 |
{ |
{ |
583 |
case 32: |
case 32: |
584 |
translate24to32(data, (uint32 *) out, (uint32 *) end); |
translate24to32(data, out, end); |
585 |
break; |
break; |
586 |
case 24: |
case 24: |
587 |
translate24to24(data, out, end); |
translate24to24(data, out, end); |
588 |
break; |
break; |
589 |
case 16: |
case 16: |
590 |
translate24to16(data, (uint16 *) out, (uint16 *) end); |
translate24to16(data, out, end); |
591 |
break; |
break; |
592 |
} |
} |
593 |
break; |
break; |
595 |
switch (g_bpp) |
switch (g_bpp) |
596 |
{ |
{ |
597 |
case 32: |
case 32: |
598 |
translate16to32((uint16 *) data, (uint32 *) out, |
translate16to32((uint16 *) data, out, end); |
|
(uint32 *) end); |
|
599 |
break; |
break; |
600 |
case 24: |
case 24: |
601 |
translate16to24((uint16 *) data, out, end); |
translate16to24((uint16 *) data, out, end); |
610 |
switch (g_bpp) |
switch (g_bpp) |
611 |
{ |
{ |
612 |
case 32: |
case 32: |
613 |
translate15to32((uint16 *) data, (uint32 *) out, |
translate15to32((uint16 *) data, out, end); |
|
(uint32 *) end); |
|
614 |
break; |
break; |
615 |
case 24: |
case 24: |
616 |
translate15to24((uint16 *) data, out, end); |
translate15to24((uint16 *) data, out, end); |
617 |
break; |
break; |
618 |
case 16: |
case 16: |
619 |
translate15to16((uint16 *) data, (uint16 *) out, |
translate15to16((uint16 *) data, out, end); |
|
(uint16 *) end); |
|
620 |
break; |
break; |
621 |
} |
} |
622 |
break; |
break; |
763 |
|
|
764 |
g_mod_map = XGetModifierMapping(g_display); |
g_mod_map = XGetModifierMapping(g_display); |
765 |
|
|
766 |
|
xkeymap_init(); |
767 |
|
|
768 |
if (g_enable_compose) |
if (g_enable_compose) |
769 |
g_IM = XOpenIM(g_display, NULL, NULL, NULL); |
g_IM = XOpenIM(g_display, NULL, NULL, NULL); |
770 |
|
|
|
xkeymap_init(); |
|
771 |
xclip_init(); |
xclip_init(); |
772 |
|
|
773 |
/* todo take this out when high colour is done */ |
/* todo take this out when high colour is done */ |
1185 |
int n = (rdp_socket > g_x_socket) ? rdp_socket + 1 : g_x_socket + 1; |
int n = (rdp_socket > g_x_socket) ? rdp_socket + 1 : g_x_socket + 1; |
1186 |
fd_set rfds, wfds; |
fd_set rfds, wfds; |
1187 |
|
|
|
FD_ZERO(&rfds); |
|
|
|
|
1188 |
while (True) |
while (True) |
1189 |
{ |
{ |
1190 |
/* Process any events already waiting */ |
/* Process any events already waiting */ |
1219 |
return 1; |
return 1; |
1220 |
|
|
1221 |
#ifdef WITH_RDPSND |
#ifdef WITH_RDPSND |
1222 |
if (FD_ISSET(g_dsp_fd, &wfds)) |
if (g_dsp_busy && FD_ISSET(g_dsp_fd, &wfds)) |
1223 |
wave_out_play(); |
wave_out_play(); |
1224 |
#endif |
#endif |
1225 |
} |
} |
1597 |
case 2: /* Hatch */ |
case 2: /* Hatch */ |
1598 |
fill = (Pixmap) ui_create_glyph(8, 8, |
fill = (Pixmap) ui_create_glyph(8, 8, |
1599 |
hatch_patterns + brush->pattern[0] * 8); |
hatch_patterns + brush->pattern[0] * 8); |
1600 |
SET_FOREGROUND(bgcolour); |
SET_FOREGROUND(fgcolour); |
1601 |
SET_BACKGROUND(fgcolour); |
SET_BACKGROUND(bgcolour); |
1602 |
XSetFillStyle(g_display, g_gc, FillOpaqueStippled); |
XSetFillStyle(g_display, g_gc, FillOpaqueStippled); |
1603 |
XSetStipple(g_display, g_gc, fill); |
XSetStipple(g_display, g_gc, fill); |
1604 |
XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin); |
XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin); |