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 |
|
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; |
uint16 pixel; |
387 |
|
uint32 value; |
388 |
|
|
389 |
while (out < end) |
while (out < end) |
390 |
{ |
{ |
391 |
|
pixel = *(data++); |
392 |
|
|
393 |
if (g_host_be) |
if (g_host_be) |
394 |
{ |
{ |
395 |
pixel = *(data++); |
BSWAP16(pixel); |
396 |
pixel = (pixel & 0xff) << 8 | (pixel & 0xff00) >> 8; |
} |
397 |
*(out++) = make_colour32(split_colour15(pixel)); |
|
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 |
else |
408 |
{ |
{ |
409 |
*(out++) = make_colour32(split_colour15(*(data++))); |
*(out++) = value; |
410 |
|
*(out++) = value >> 8; |
411 |
|
*(out++) = value >> 16; |
412 |
|
*(out++) = value >> 24; |
413 |
} |
} |
414 |
} |
} |
415 |
} |
} |
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; |
uint16 pixel; |
481 |
|
uint32 value; |
482 |
|
|
483 |
while (out < end) |
while (out < end) |
484 |
{ |
{ |
485 |
|
pixel = *(data++); |
486 |
|
|
487 |
if (g_host_be) |
if (g_host_be) |
488 |
{ |
{ |
489 |
pixel = *(data++); |
BSWAP16(pixel)} |
490 |
pixel = (pixel & 0xff) << 8 | (pixel & 0xff00) >> 8; |
|
491 |
*(out++) = make_colour32(split_colour16(pixel)); |
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 |
else |
501 |
{ |
{ |
502 |
*(out++) = make_colour32(split_colour16(*(data++))); |
*(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 |
if (g_host_be) |
if (g_xserver_be) |
551 |
{ |
{ |
552 |
pixel = *(data++) << 16; |
*(out++) = 0x00; |
553 |
pixel |= *(data++) << 8; |
*(out++) = *(data++); |
554 |
pixel |= *(data++); |
*(out++) = *(data++); |
555 |
|
*(out++) = *(data++); |
556 |
} |
} |
557 |
else |
else |
558 |
{ |
{ |
559 |
pixel = *(data++); |
*(out++) = *(data++); |
560 |
pixel |= *(data++) << 8; |
*(out++) = *(data++); |
561 |
pixel |= *(data++) << 16; |
*(out++) = *(data++); |
562 |
|
*(out++) = 0x00; |
563 |
} |
} |
|
*(out++) = pixel; |
|
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; |
759 |
|
|
760 |
g_mod_map = XGetModifierMapping(g_display); |
g_mod_map = XGetModifierMapping(g_display); |
761 |
|
|
762 |
|
xkeymap_init(); |
763 |
|
|
764 |
if (g_enable_compose) |
if (g_enable_compose) |
765 |
g_IM = XOpenIM(g_display, NULL, NULL, NULL); |
g_IM = XOpenIM(g_display, NULL, NULL, NULL); |
766 |
|
|
|
xkeymap_init(); |
|
767 |
xclip_init(); |
xclip_init(); |
768 |
|
|
769 |
/* todo take this out when high colour is done */ |
/* todo take this out when high colour is done */ |
1199 |
{ |
{ |
1200 |
FD_SET(g_dsp_fd, &wfds); |
FD_SET(g_dsp_fd, &wfds); |
1201 |
n = (g_dsp_fd + 1 > n) ? g_dsp_fd + 1 : n; |
n = (g_dsp_fd + 1 > n) ? g_dsp_fd + 1 : n; |
1202 |
} |
} |
1203 |
#endif |
#endif |
1204 |
|
|
1205 |
switch (select(n, &rfds, &wfds, NULL, NULL)) |
switch (select(n, &rfds, &wfds, NULL, NULL)) |
1593 |
case 2: /* Hatch */ |
case 2: /* Hatch */ |
1594 |
fill = (Pixmap) ui_create_glyph(8, 8, |
fill = (Pixmap) ui_create_glyph(8, 8, |
1595 |
hatch_patterns + brush->pattern[0] * 8); |
hatch_patterns + brush->pattern[0] * 8); |
1596 |
SET_FOREGROUND(bgcolour); |
SET_FOREGROUND(fgcolour); |
1597 |
SET_BACKGROUND(fgcolour); |
SET_BACKGROUND(bgcolour); |
1598 |
XSetFillStyle(g_display, g_gc, FillOpaqueStippled); |
XSetFillStyle(g_display, g_gc, FillOpaqueStippled); |
1599 |
XSetStipple(g_display, g_gc, fill); |
XSetStipple(g_display, g_gc, fill); |
1600 |
XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin); |
XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin); |