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; |
66 |
static int g_move_x_offset = 0; |
static int g_move_x_offset = 0; |
67 |
static int g_move_y_offset = 0; |
static int g_move_y_offset = 0; |
68 |
|
|
69 |
|
#ifdef WITH_RDPSND |
70 |
|
extern int g_dsp_fd; |
71 |
|
extern BOOL g_dsp_busy; |
72 |
|
#endif |
73 |
|
|
74 |
/* MWM decorations */ |
/* MWM decorations */ |
75 |
#define MWM_HINTS_DECORATIONS (1L << 1) |
#define MWM_HINTS_DECORATIONS (1L << 1) |
76 |
#define PROP_MOTIF_WM_HINTS_ELEMENTS 5 |
#define PROP_MOTIF_WM_HINTS_ELEMENTS 5 |
206 |
static uint32 |
static uint32 |
207 |
make_colour24(PixelColour pc) |
make_colour24(PixelColour pc) |
208 |
{ |
{ |
209 |
return (pc.red << 16) | (pc.green << 8) | pc.blue; |
if (g_xserver_be) |
210 |
|
{ |
211 |
|
return pc.red | (pc.green << 8) | (pc.blue << 16); |
212 |
|
} |
213 |
|
else |
214 |
|
{ |
215 |
|
return (pc.red << 16) | (pc.green << 8) | pc.blue; |
216 |
|
} |
217 |
} |
} |
218 |
|
|
219 |
static uint32 |
static uint32 |
220 |
make_colour32(PixelColour pc) |
make_colour32(PixelColour pc) |
221 |
{ |
{ |
222 |
return (pc.red << 16) | (pc.green << 8) | pc.blue; |
if (g_xserver_be) |
223 |
|
{ |
224 |
|
return pc.red | (pc.green << 8) | (pc.blue << 16); |
225 |
|
} |
226 |
|
else |
227 |
|
{ |
228 |
|
return (pc.red << 16) | (pc.green << 8) | pc.blue; |
229 |
|
} |
230 |
} |
} |
231 |
|
|
232 |
#define BSWAP16(x) { x = (((x & 0xff) << 8) | (x >> 8)); } |
#define BSWAP16(x) { x = (((x & 0xff) << 8) | (x >> 8)); } |
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 |
|
value = make_colour16(split_colour15(pixel)); |
339 |
|
|
340 |
|
if (g_xserver_be) |
341 |
|
{ |
342 |
|
*(out++) = value >> 8; |
343 |
|
*(out++) = value; |
344 |
|
} |
345 |
|
else |
346 |
|
{ |
347 |
|
*(out++) = value; |
348 |
|
*(out++) = value >> 8; |
349 |
|
} |
350 |
|
} |
351 |
} |
} |
352 |
|
|
353 |
static void |
static void |
354 |
translate15to24(uint16 * data, uint8 * out, uint8 * end) |
translate15to24(uint16 * data, uint8 * out, uint8 * end) |
355 |
{ |
{ |
356 |
uint32 value; |
uint32 value; |
357 |
|
uint16 pixel; |
358 |
|
|
359 |
while (out < end) |
while (out < end) |
360 |
{ |
{ |
361 |
value = make_colour24(split_colour15(*(data++))); |
pixel = *(data++); |
362 |
*(out++) = value; |
|
363 |
*(out++) = value >> 8; |
if (g_host_be) |
364 |
*(out++) = value >> 16; |
{ |
365 |
|
BSWAP16(pixel)} |
366 |
|
|
367 |
|
value = make_colour24(split_colour15(pixel)); |
368 |
|
if (g_xserver_be) |
369 |
|
{ |
370 |
|
*(out++) = value >> 16; |
371 |
|
*(out++) = value >> 8; |
372 |
|
*(out++) = value; |
373 |
|
} |
374 |
|
else |
375 |
|
{ |
376 |
|
*(out++) = value; |
377 |
|
*(out++) = value >> 8; |
378 |
|
*(out++) = value >> 16; |
379 |
|
} |
380 |
} |
} |
381 |
} |
} |
382 |
|
|
383 |
static void |
static void |
384 |
translate15to32(uint16 * data, uint32 * out, uint32 * end) |
translate15to32(uint16 * data, uint8 * out, uint8 * end) |
385 |
{ |
{ |
386 |
|
uint16 pixel; |
387 |
|
uint32 value; |
388 |
|
|
389 |
while (out < end) |
while (out < end) |
390 |
*(out++) = make_colour32(split_colour15(*(data++))); |
{ |
391 |
|
pixel = *(data++); |
392 |
|
|
393 |
|
if (g_host_be) |
394 |
|
{ |
395 |
|
BSWAP16(pixel); |
396 |
|
} |
397 |
|
|
398 |
|
value = make_colour32(split_colour15(pixel)); |
399 |
|
|
400 |
|
if (g_xserver_be) |
401 |
|
{ |
402 |
|
*(out++) = value >> 24; |
403 |
|
*(out++) = value >> 16; |
404 |
|
*(out++) = value >> 8; |
405 |
|
*(out++) = value; |
406 |
|
} |
407 |
|
else |
408 |
|
{ |
409 |
|
*(out++) = value; |
410 |
|
*(out++) = value >> 8; |
411 |
|
*(out++) = value >> 16; |
412 |
|
*(out++) = value >> 24; |
413 |
|
} |
414 |
|
} |
415 |
} |
} |
416 |
|
|
417 |
static void |
static void |
418 |
translate16to16(uint16 * data, uint16 * out, uint16 * end) |
translate16to16(uint16 * data, uint16 * out, uint16 * end) |
419 |
{ |
{ |
420 |
while (out < end) |
uint16 value; |
421 |
*(out++) = (uint16) (*(data++)); |
|
422 |
|
if (g_xserver_be) |
423 |
|
{ |
424 |
|
while (out < end) |
425 |
|
{ |
426 |
|
value = *data; |
427 |
|
BSWAP16(value); |
428 |
|
*out = value; |
429 |
|
data++; |
430 |
|
out++; |
431 |
|
} |
432 |
|
|
433 |
|
} |
434 |
|
else |
435 |
|
{ |
436 |
|
while (out < end) |
437 |
|
{ |
438 |
|
*out = *data; |
439 |
|
out++; |
440 |
|
data++; |
441 |
|
} |
442 |
|
} |
443 |
} |
} |
444 |
|
|
445 |
|
|
447 |
translate16to24(uint16 * data, uint8 * out, uint8 * end) |
translate16to24(uint16 * data, uint8 * out, uint8 * end) |
448 |
{ |
{ |
449 |
uint32 value; |
uint32 value; |
450 |
|
uint16 pixel; |
451 |
|
|
452 |
while (out < end) |
while (out < end) |
453 |
{ |
{ |
454 |
value = make_colour24(split_colour16(*(data++))); |
pixel = *(data++); |
455 |
*(out++) = value; |
|
456 |
*(out++) = value >> 8; |
if (g_host_be) |
457 |
*(out++) = value >> 16; |
{ |
458 |
|
BSWAP16(pixel)} |
459 |
|
|
460 |
|
value = make_colour24(split_colour16(pixel)); |
461 |
|
|
462 |
|
if (g_xserver_be) |
463 |
|
{ |
464 |
|
*(out++) = value >> 16; |
465 |
|
*(out++) = value >> 8; |
466 |
|
*(out++) = value; |
467 |
|
} |
468 |
|
else |
469 |
|
{ |
470 |
|
*(out++) = value; |
471 |
|
*(out++) = value >> 8; |
472 |
|
*(out++) = value >> 16; |
473 |
|
} |
474 |
} |
} |
475 |
} |
} |
476 |
|
|
477 |
static void |
static void |
478 |
translate16to32(uint16 * data, uint32 * out, uint32 * end) |
translate16to32(uint16 * data, uint8 * out, uint8 * end) |
479 |
{ |
{ |
480 |
|
uint16 pixel; |
481 |
|
uint32 value; |
482 |
|
|
483 |
while (out < end) |
while (out < end) |
484 |
*(out++) = make_colour32(split_colour16(*(data++))); |
{ |
485 |
|
pixel = *(data++); |
486 |
|
|
487 |
|
if (g_host_be) |
488 |
|
{ |
489 |
|
BSWAP16(pixel)} |
490 |
|
|
491 |
|
value = make_colour32(split_colour16(pixel)); |
492 |
|
|
493 |
|
if (g_xserver_be) |
494 |
|
{ |
495 |
|
*(out++) = value >> 24; |
496 |
|
*(out++) = value >> 16; |
497 |
|
*(out++) = value >> 8; |
498 |
|
*(out++) = value; |
499 |
|
} |
500 |
|
else |
501 |
|
{ |
502 |
|
*(out++) = value; |
503 |
|
*(out++) = value >> 8; |
504 |
|
*(out++) = value >> 16; |
505 |
|
*(out++) = value >> 24; |
506 |
|
} |
507 |
|
} |
508 |
} |
} |
509 |
|
|
510 |
static void |
static void |
511 |
translate24to16(uint8 * data, uint16 * out, uint16 * end) |
translate24to16(uint8 * data, uint8 * out, uint8 * end) |
512 |
{ |
{ |
513 |
uint32 pixel = 0; |
uint32 pixel = 0; |
514 |
|
uint16 value; |
515 |
while (out < end) |
while (out < end) |
516 |
{ |
{ |
517 |
pixel = *(data++) << 16; |
pixel = *(data++) << 16; |
518 |
pixel |= *(data++) << 8; |
pixel |= *(data++) << 8; |
519 |
pixel |= *(data++); |
pixel |= *(data++); |
520 |
*(out++) = (uint16) make_colour16(split_colour24(pixel)); |
|
521 |
|
value = (uint16) make_colour16(split_colour24(pixel)); |
522 |
|
|
523 |
|
if (g_xserver_be) |
524 |
|
{ |
525 |
|
*(out++) = value >> 8; |
526 |
|
*(out++) = value; |
527 |
|
} |
528 |
|
else |
529 |
|
{ |
530 |
|
*(out++) = value; |
531 |
|
*(out++) = value >> 8; |
532 |
|
} |
533 |
} |
} |
534 |
} |
} |
535 |
|
|
543 |
} |
} |
544 |
|
|
545 |
static void |
static void |
546 |
translate24to32(uint8 * data, uint32 * out, uint32 * end) |
translate24to32(uint8 * data, uint8 * out, uint8 * end) |
547 |
{ |
{ |
|
uint32 pixel = 0; |
|
548 |
while (out < end) |
while (out < end) |
549 |
{ |
{ |
550 |
pixel = *(data++); |
if (g_xserver_be) |
551 |
pixel |= *(data++) << 8; |
{ |
552 |
pixel |= *(data++) << 16; |
*(out++) = 0x00; |
553 |
*(out++) = pixel; |
*(out++) = *(data++); |
554 |
|
*(out++) = *(data++); |
555 |
|
*(out++) = *(data++); |
556 |
|
} |
557 |
|
else |
558 |
|
{ |
559 |
|
*(out++) = *(data++); |
560 |
|
*(out++) = *(data++); |
561 |
|
*(out++) = *(data++); |
562 |
|
*(out++) = 0x00; |
563 |
|
} |
564 |
} |
} |
565 |
} |
} |
566 |
|
|
577 |
switch (g_bpp) |
switch (g_bpp) |
578 |
{ |
{ |
579 |
case 32: |
case 32: |
580 |
translate24to32(data, (uint32 *) out, (uint32 *) end); |
translate24to32(data, out, end); |
581 |
break; |
break; |
582 |
case 24: |
case 24: |
583 |
translate24to24(data, out, end); |
translate24to24(data, out, end); |
584 |
break; |
break; |
585 |
case 16: |
case 16: |
586 |
translate24to16(data, (uint16 *) out, (uint16 *) end); |
translate24to16(data, out, end); |
587 |
break; |
break; |
588 |
} |
} |
589 |
break; |
break; |
591 |
switch (g_bpp) |
switch (g_bpp) |
592 |
{ |
{ |
593 |
case 32: |
case 32: |
594 |
translate16to32((uint16 *) data, (uint32 *) out, |
translate16to32((uint16 *) data, out, end); |
|
(uint32 *) end); |
|
595 |
break; |
break; |
596 |
case 24: |
case 24: |
597 |
translate16to24((uint16 *) data, out, end); |
translate16to24((uint16 *) data, out, end); |
606 |
switch (g_bpp) |
switch (g_bpp) |
607 |
{ |
{ |
608 |
case 32: |
case 32: |
609 |
translate15to32((uint16 *) data, (uint32 *) out, |
translate15to32((uint16 *) data, out, end); |
|
(uint32 *) end); |
|
610 |
break; |
break; |
611 |
case 24: |
case 24: |
612 |
translate15to24((uint16 *) data, out, end); |
translate15to24((uint16 *) data, out, end); |
613 |
break; |
break; |
614 |
case 16: |
case 16: |
615 |
translate15to16((uint16 *) data, (uint16 *) out, |
translate15to16((uint16 *) data, out, end); |
|
(uint16 *) end); |
|
616 |
break; |
break; |
617 |
} |
} |
618 |
break; |
break; |
719 |
g_host_be = !(BOOL) (*(uint8 *) (&test)); |
g_host_be = !(BOOL) (*(uint8 *) (&test)); |
720 |
g_xserver_be = (ImageByteOrder(g_display) == MSBFirst); |
g_xserver_be = (ImageByteOrder(g_display) == MSBFirst); |
721 |
|
|
722 |
if ((g_width == 0) || (g_height == 0)) |
/* |
723 |
|
* Determine desktop size |
724 |
|
*/ |
725 |
|
if (g_width < 0) |
726 |
|
{ |
727 |
|
/* Percent of screen */ |
728 |
|
g_height = HeightOfScreen(g_screen) * (-g_width) / 100; |
729 |
|
g_width = WidthOfScreen(g_screen) * (-g_width) / 100; |
730 |
|
} |
731 |
|
else if (g_width == 0) |
732 |
{ |
{ |
733 |
/* Fetch geometry from _NET_WORKAREA */ |
/* Fetch geometry from _NET_WORKAREA */ |
734 |
uint32 x, y, cx, cy; |
uint32 x, y, cx, cy; |
745 |
g_height = 600; |
g_height = 600; |
746 |
} |
} |
747 |
} |
} |
748 |
|
else if (g_fullscreen) |
|
if (g_fullscreen) |
|
749 |
{ |
{ |
750 |
g_width = WidthOfScreen(g_screen); |
g_width = WidthOfScreen(g_screen); |
751 |
g_height = HeightOfScreen(g_screen); |
g_height = HeightOfScreen(g_screen); |
767 |
|
|
768 |
g_mod_map = XGetModifierMapping(g_display); |
g_mod_map = XGetModifierMapping(g_display); |
769 |
|
|
770 |
|
xkeymap_init(); |
771 |
|
|
772 |
if (g_enable_compose) |
if (g_enable_compose) |
773 |
g_IM = XOpenIM(g_display, NULL, NULL, NULL); |
g_IM = XOpenIM(g_display, NULL, NULL, NULL); |
774 |
|
|
|
xkeymap_init(); |
|
775 |
xclip_init(); |
xclip_init(); |
776 |
|
|
777 |
/* todo take this out when high colour is done */ |
/* todo take this out when high colour is done */ |
1187 |
ui_select(int rdp_socket) |
ui_select(int rdp_socket) |
1188 |
{ |
{ |
1189 |
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; |
1190 |
fd_set rfds; |
fd_set rfds, wfds; |
|
|
|
|
FD_ZERO(&rfds); |
|
1191 |
|
|
1192 |
while (True) |
while (True) |
1193 |
{ |
{ |
1197 |
return 0; |
return 0; |
1198 |
|
|
1199 |
FD_ZERO(&rfds); |
FD_ZERO(&rfds); |
1200 |
|
FD_ZERO(&wfds); |
1201 |
FD_SET(rdp_socket, &rfds); |
FD_SET(rdp_socket, &rfds); |
1202 |
FD_SET(g_x_socket, &rfds); |
FD_SET(g_x_socket, &rfds); |
1203 |
|
|
1204 |
switch (select(n, &rfds, NULL, NULL, NULL)) |
#ifdef WITH_RDPSND |
1205 |
|
/* FIXME: there should be an API for registering fds */ |
1206 |
|
if (g_dsp_busy) |
1207 |
|
{ |
1208 |
|
FD_SET(g_dsp_fd, &wfds); |
1209 |
|
n = (g_dsp_fd + 1 > n) ? g_dsp_fd + 1 : n; |
1210 |
|
} |
1211 |
|
#endif |
1212 |
|
|
1213 |
|
switch (select(n, &rfds, &wfds, NULL, NULL)) |
1214 |
{ |
{ |
1215 |
case -1: |
case -1: |
1216 |
error("select: %s\n", strerror(errno)); |
error("select: %s\n", strerror(errno)); |
1221 |
|
|
1222 |
if (FD_ISSET(rdp_socket, &rfds)) |
if (FD_ISSET(rdp_socket, &rfds)) |
1223 |
return 1; |
return 1; |
1224 |
|
|
1225 |
|
#ifdef WITH_RDPSND |
1226 |
|
if (g_dsp_busy && FD_ISSET(g_dsp_fd, &wfds)) |
1227 |
|
wave_out_play(); |
1228 |
|
#endif |
1229 |
} |
} |
1230 |
} |
} |
1231 |
|
|
1601 |
case 2: /* Hatch */ |
case 2: /* Hatch */ |
1602 |
fill = (Pixmap) ui_create_glyph(8, 8, |
fill = (Pixmap) ui_create_glyph(8, 8, |
1603 |
hatch_patterns + brush->pattern[0] * 8); |
hatch_patterns + brush->pattern[0] * 8); |
1604 |
SET_FOREGROUND(bgcolour); |
SET_FOREGROUND(fgcolour); |
1605 |
SET_BACKGROUND(fgcolour); |
SET_BACKGROUND(bgcolour); |
1606 |
XSetFillStyle(g_display, g_gc, FillOpaqueStippled); |
XSetFillStyle(g_display, g_gc, FillOpaqueStippled); |
1607 |
XSetStipple(g_display, g_gc, fill); |
XSetStipple(g_display, g_gc, fill); |
1608 |
XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin); |
XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin); |