49 |
static XIC g_IC; |
static XIC g_IC; |
50 |
static XModifierKeymap *g_mod_map; |
static XModifierKeymap *g_mod_map; |
51 |
static Cursor g_current_cursor; |
static Cursor g_current_cursor; |
52 |
|
static HCURSOR g_null_cursor; |
53 |
static Atom g_protocol_atom, g_kill_atom; |
static Atom g_protocol_atom, g_kill_atom; |
54 |
static BOOL g_focused; |
static BOOL g_focused; |
55 |
static BOOL g_mouse_in_wnd; |
static BOOL g_mouse_in_wnd; |
57 |
/* endianness */ |
/* endianness */ |
58 |
static BOOL g_host_be; |
static BOOL g_host_be; |
59 |
static BOOL g_xserver_be; |
static BOOL g_xserver_be; |
60 |
|
static BOOL g_xserver_bgr; |
61 |
|
|
62 |
/* software backing store */ |
/* software backing store */ |
63 |
static BOOL g_ownbackstore; |
static BOOL g_ownbackstore; |
71 |
#ifdef WITH_RDPSND |
#ifdef WITH_RDPSND |
72 |
extern int g_dsp_fd; |
extern int g_dsp_fd; |
73 |
extern BOOL g_dsp_busy; |
extern BOOL g_dsp_busy; |
74 |
|
extern BOOL g_rdpsnd; |
75 |
#endif |
#endif |
76 |
|
|
77 |
/* MWM decorations */ |
/* MWM decorations */ |
203 |
pc.red = (pc.red * 0x1f) / 0xff; |
pc.red = (pc.red * 0x1f) / 0xff; |
204 |
pc.green = (pc.green * 0x3f) / 0xff; |
pc.green = (pc.green * 0x3f) / 0xff; |
205 |
pc.blue = (pc.blue * 0x1f) / 0xff; |
pc.blue = (pc.blue * 0x1f) / 0xff; |
206 |
return (pc.red << 11) | (pc.green << 5) | pc.blue; |
if (g_xserver_bgr) |
207 |
|
return (pc.blue << 11) | (pc.green << 5) | pc.red; |
208 |
|
else |
209 |
|
return (pc.red << 11) | (pc.green << 5) | pc.blue; |
210 |
|
|
211 |
} |
} |
212 |
|
|
213 |
static uint32 |
static uint32 |
214 |
make_colour24(PixelColour pc) |
make_colour24(PixelColour pc) |
215 |
{ |
{ |
216 |
if (g_xserver_be) |
if (g_xserver_bgr) |
217 |
{ |
return (pc.blue << 16) | (pc.green << 8) | pc.red; |
|
return pc.red | (pc.green << 8) | (pc.blue << 16); |
|
|
} |
|
218 |
else |
else |
|
{ |
|
219 |
return (pc.red << 16) | (pc.green << 8) | pc.blue; |
return (pc.red << 16) | (pc.green << 8) | pc.blue; |
|
} |
|
220 |
} |
} |
221 |
|
|
222 |
static uint32 |
static uint32 |
223 |
make_colour32(PixelColour pc) |
make_colour32(PixelColour pc) |
224 |
{ |
{ |
225 |
if (g_xserver_be) |
if (g_xserver_bgr) |
226 |
{ |
return (pc.blue << 16) | (pc.green << 8) | pc.red; |
|
return pc.red | (pc.green << 8) | (pc.blue << 16); |
|
|
} |
|
227 |
else |
else |
|
{ |
|
228 |
return (pc.red << 16) | (pc.green << 8) | pc.blue; |
return (pc.red << 16) | (pc.green << 8) | pc.blue; |
|
} |
|
229 |
} |
} |
230 |
|
|
231 |
#define BSWAP16(x) { x = (((x & 0xff) << 8) | (x >> 8)); } |
#define BSWAP16(x) { x = (((x & 0xff) << 8) | (x >> 8)); } |
272 |
colour = make_colour16(split_colour24(colour)); |
colour = make_colour16(split_colour24(colour)); |
273 |
break; |
break; |
274 |
case 24: |
case 24: |
275 |
|
colour = make_colour24(split_colour24(colour)); |
276 |
break; |
break; |
277 |
case 32: |
case 32: |
278 |
colour = make_colour32(split_colour24(colour)); |
colour = make_colour32(split_colour24(colour)); |
291 |
} |
} |
292 |
|
|
293 |
static void |
static void |
294 |
translate8to16(uint8 * data, uint16 * out, uint16 * end) |
translate8to16(uint8 * data, uint8 * out, uint8 * end) |
295 |
{ |
{ |
296 |
|
uint16 value; |
297 |
|
|
298 |
while (out < end) |
while (out < end) |
299 |
*(out++) = (uint16) g_colmap[*(data++)]; |
{ |
300 |
|
value = (uint16) g_colmap[*(data++)]; |
301 |
|
|
302 |
|
if (g_xserver_be) |
303 |
|
{ |
304 |
|
*(out++) = value >> 8; |
305 |
|
*(out++) = value; |
306 |
|
} |
307 |
|
else |
308 |
|
{ |
309 |
|
*(out++) = value; |
310 |
|
*(out++) = value >> 8; |
311 |
|
} |
312 |
|
} |
313 |
} |
} |
314 |
|
|
315 |
/* little endian - conversion happens when colourmap is built */ |
/* little endian - conversion happens when colourmap is built */ |
321 |
while (out < end) |
while (out < end) |
322 |
{ |
{ |
323 |
value = g_colmap[*(data++)]; |
value = g_colmap[*(data++)]; |
324 |
*(out++) = value; |
|
325 |
*(out++) = value >> 8; |
if (g_xserver_be) |
326 |
*(out++) = value >> 16; |
{ |
327 |
|
*(out++) = value >> 16; |
328 |
|
*(out++) = value >> 8; |
329 |
|
*(out++) = value; |
330 |
|
} |
331 |
|
else |
332 |
|
{ |
333 |
|
*(out++) = value; |
334 |
|
*(out++) = value >> 8; |
335 |
|
*(out++) = value >> 16; |
336 |
|
} |
337 |
} |
} |
338 |
} |
} |
339 |
|
|
340 |
static void |
static void |
341 |
translate8to32(uint8 * data, uint32 * out, uint32 * end) |
translate8to32(uint8 * data, uint8 * out, uint8 * end) |
342 |
{ |
{ |
343 |
|
uint32 value; |
344 |
|
|
345 |
while (out < end) |
while (out < end) |
346 |
*(out++) = g_colmap[*(data++)]; |
{ |
347 |
|
value = g_colmap[*(data++)]; |
348 |
|
|
349 |
|
if (g_xserver_be) |
350 |
|
{ |
351 |
|
*(out++) = value >> 24; |
352 |
|
*(out++) = value >> 16; |
353 |
|
*(out++) = value >> 8; |
354 |
|
*(out++) = value; |
355 |
|
} |
356 |
|
else |
357 |
|
{ |
358 |
|
*(out++) = value; |
359 |
|
*(out++) = value >> 8; |
360 |
|
*(out++) = value >> 16; |
361 |
|
*(out++) = value >> 24; |
362 |
|
} |
363 |
|
} |
364 |
} |
} |
365 |
|
|
366 |
/* todo the remaining translate function might need some big endian check ?? */ |
/* todo the remaining translate function might need some big endian check ?? */ |
377 |
|
|
378 |
if (g_host_be) |
if (g_host_be) |
379 |
{ |
{ |
380 |
BSWAP16(pixel) |
BSWAP16(pixel); |
381 |
} |
} |
382 |
|
|
383 |
value = make_colour16(split_colour15(pixel)); |
value = make_colour16(split_colour15(pixel)); |
407 |
|
|
408 |
if (g_host_be) |
if (g_host_be) |
409 |
{ |
{ |
410 |
BSWAP16(pixel) |
BSWAP16(pixel); |
411 |
} |
} |
412 |
|
|
413 |
value = make_colour24(split_colour15(pixel)); |
value = make_colour24(split_colour15(pixel)); |
501 |
|
|
502 |
if (g_host_be) |
if (g_host_be) |
503 |
{ |
{ |
504 |
BSWAP16(pixel) |
BSWAP16(pixel); |
505 |
} |
} |
506 |
|
|
507 |
value = make_colour24(split_colour16(pixel)); |
value = make_colour24(split_colour16(pixel)); |
533 |
|
|
534 |
if (g_host_be) |
if (g_host_be) |
535 |
{ |
{ |
536 |
BSWAP16(pixel) |
BSWAP16(pixel)} |
|
} |
|
537 |
|
|
538 |
value = make_colour32(split_colour16(pixel)); |
value = make_colour32(split_colour16(pixel)); |
539 |
|
|
543 |
*(out++) = value >> 16; |
*(out++) = value >> 16; |
544 |
*(out++) = value >> 8; |
*(out++) = value >> 8; |
545 |
*(out++) = value; |
*(out++) = value; |
546 |
} |
} |
547 |
else |
else |
548 |
{ |
{ |
549 |
*(out++) = value; |
*(out++) = value; |
550 |
*(out++) = value >> 8; |
*(out++) = value >> 8; |
551 |
*(out++) = value >> 16; |
*(out++) = value >> 16; |
552 |
*(out++) = value >> 24; |
*(out++) = value >> 24; |
553 |
} |
} |
554 |
} |
} |
555 |
} |
} |
556 |
|
|
557 |
static void |
static void |
670 |
translate8to8(data, out, end); |
translate8to8(data, out, end); |
671 |
break; |
break; |
672 |
case 16: |
case 16: |
673 |
translate8to16(data, (uint16 *) out, (uint16 *) end); |
translate8to16(data, out, end); |
674 |
break; |
break; |
675 |
case 24: |
case 24: |
676 |
translate8to24(data, out, end); |
translate8to24(data, out, end); |
677 |
break; |
break; |
678 |
case 32: |
case 32: |
679 |
translate8to32(data, (uint32 *) out, (uint32 *) end); |
translate8to32(data, out, end); |
680 |
break; |
break; |
681 |
} |
} |
682 |
break; |
break; |
750 |
return False; |
return False; |
751 |
} |
} |
752 |
|
|
753 |
if (g_owncolmap != True) |
/* private colour map code only works for 8 bpp */ |
754 |
|
if (g_owncolmap && (g_bpp > 8)) |
755 |
|
g_owncolmap = False; |
756 |
|
|
757 |
|
if (!g_owncolmap) |
758 |
{ |
{ |
759 |
g_xcolmap = DefaultColormapOfScreen(g_screen); |
g_xcolmap = DefaultColormapOfScreen(g_screen); |
760 |
if (g_depth <= 8) |
if (g_depth <= 8) |
769 |
test = 1; |
test = 1; |
770 |
g_host_be = !(BOOL) (*(uint8 *) (&test)); |
g_host_be = !(BOOL) (*(uint8 *) (&test)); |
771 |
g_xserver_be = (ImageByteOrder(g_display) == MSBFirst); |
g_xserver_be = (ImageByteOrder(g_display) == MSBFirst); |
772 |
|
g_xserver_bgr = (g_visual->blue_mask > g_visual->red_mask); |
773 |
|
|
774 |
if ((g_width == 0) || (g_height == 0)) |
/* |
775 |
|
* Determine desktop size |
776 |
|
*/ |
777 |
|
if (g_width < 0) |
778 |
|
{ |
779 |
|
/* Percent of screen */ |
780 |
|
g_height = HeightOfScreen(g_screen) * (-g_width) / 100; |
781 |
|
g_width = WidthOfScreen(g_screen) * (-g_width) / 100; |
782 |
|
} |
783 |
|
else if (g_width == 0) |
784 |
{ |
{ |
785 |
/* Fetch geometry from _NET_WORKAREA */ |
/* Fetch geometry from _NET_WORKAREA */ |
786 |
uint32 x, y, cx, cy; |
uint32 x, y, cx, cy; |
797 |
g_height = 600; |
g_height = 600; |
798 |
} |
} |
799 |
} |
} |
800 |
|
else if (g_fullscreen) |
|
if (g_fullscreen) |
|
801 |
{ |
{ |
802 |
g_width = WidthOfScreen(g_screen); |
g_width = WidthOfScreen(g_screen); |
803 |
g_height = HeightOfScreen(g_screen); |
g_height = HeightOfScreen(g_screen); |
826 |
|
|
827 |
xclip_init(); |
xclip_init(); |
828 |
|
|
829 |
/* todo take this out when high colour is done */ |
DEBUG_RDP5(("server bpp %d client bpp %d depth %d\n", g_server_bpp, g_bpp, g_depth)); |
|
printf("server bpp %d client bpp %d depth %d\n", g_server_bpp, g_bpp, g_depth); |
|
830 |
|
|
831 |
return True; |
return True; |
832 |
} |
} |
847 |
g_display = NULL; |
g_display = NULL; |
848 |
} |
} |
849 |
|
|
850 |
|
#define NULL_POINTER_MASK "\x80" |
851 |
|
#define NULL_POINTER_DATA "\x0\x0\x0" |
852 |
|
|
853 |
BOOL |
BOOL |
854 |
ui_create_window(void) |
ui_create_window(void) |
855 |
{ |
{ |
934 |
g_kill_atom = XInternAtom(g_display, "WM_DELETE_WINDOW", True); |
g_kill_atom = XInternAtom(g_display, "WM_DELETE_WINDOW", True); |
935 |
XSetWMProtocols(g_display, g_wnd, &g_kill_atom, 1); |
XSetWMProtocols(g_display, g_wnd, &g_kill_atom, 1); |
936 |
|
|
937 |
|
/* create invisible 1x1 cursor to be used as null cursor */ |
938 |
|
g_null_cursor = ui_create_cursor(0, 0, 1, 1, NULL_POINTER_MASK, NULL_POINTER_DATA); |
939 |
|
|
940 |
return True; |
return True; |
941 |
} |
} |
942 |
|
|
943 |
void |
void |
944 |
ui_destroy_window(void) |
ui_destroy_window(void) |
945 |
{ |
{ |
946 |
|
ui_destroy_cursor(g_null_cursor); |
947 |
|
|
948 |
if (g_IC != NULL) |
if (g_IC != NULL) |
949 |
XDestroyIC(g_IC); |
XDestroyIC(g_IC); |
950 |
|
|
1266 |
{ |
{ |
1267 |
FD_SET(g_dsp_fd, &wfds); |
FD_SET(g_dsp_fd, &wfds); |
1268 |
n = (g_dsp_fd + 1 > n) ? g_dsp_fd + 1 : n; |
n = (g_dsp_fd + 1 > n) ? g_dsp_fd + 1 : n; |
1269 |
} |
} |
1270 |
#endif |
#endif |
1271 |
|
|
1272 |
switch (select(n, &rfds, &wfds, NULL, NULL)) |
switch (select(n, &rfds, &wfds, NULL, NULL)) |
1300 |
XImage *image; |
XImage *image; |
1301 |
Pixmap bitmap; |
Pixmap bitmap; |
1302 |
uint8 *tdata; |
uint8 *tdata; |
1303 |
|
int bitmap_pad; |
1304 |
|
|
1305 |
|
if (g_server_bpp == 8) |
1306 |
|
{ |
1307 |
|
bitmap_pad = 8; |
1308 |
|
} |
1309 |
|
else |
1310 |
|
{ |
1311 |
|
bitmap_pad = g_bpp; |
1312 |
|
|
1313 |
|
if (g_bpp == 24) |
1314 |
|
bitmap_pad = 32; |
1315 |
|
} |
1316 |
|
|
1317 |
tdata = (g_owncolmap ? data : translate_image(width, height, data)); |
tdata = (g_owncolmap ? data : translate_image(width, height, data)); |
1318 |
bitmap = XCreatePixmap(g_display, g_wnd, width, height, g_depth); |
bitmap = XCreatePixmap(g_display, g_wnd, width, height, g_depth); |
1319 |
image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0, |
image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0, |
1320 |
(char *) tdata, width, height, g_server_bpp == 8 ? 8 : g_bpp, 0); |
(char *) tdata, width, height, bitmap_pad, 0); |
1321 |
|
|
1322 |
XPutImage(g_display, bitmap, g_gc, image, 0, 0, 0, 0, width, height); |
XPutImage(g_display, bitmap, g_gc, image, 0, 0, 0, 0, width, height); |
1323 |
|
|
1332 |
{ |
{ |
1333 |
XImage *image; |
XImage *image; |
1334 |
uint8 *tdata; |
uint8 *tdata; |
1335 |
|
int bitmap_pad; |
1336 |
|
|
1337 |
|
if (g_server_bpp == 8) |
1338 |
|
{ |
1339 |
|
bitmap_pad = 8; |
1340 |
|
} |
1341 |
|
else |
1342 |
|
{ |
1343 |
|
bitmap_pad = g_bpp; |
1344 |
|
|
1345 |
|
if (g_bpp == 24) |
1346 |
|
bitmap_pad = 32; |
1347 |
|
} |
1348 |
|
|
1349 |
tdata = (g_owncolmap ? data : translate_image(width, height, data)); |
tdata = (g_owncolmap ? data : translate_image(width, height, data)); |
1350 |
image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0, |
image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0, |
1351 |
(char *) tdata, width, height, g_server_bpp == 8 ? 8 : g_bpp, 0); |
(char *) tdata, width, height, bitmap_pad, 0); |
1352 |
|
|
1353 |
if (g_ownbackstore) |
if (g_ownbackstore) |
1354 |
{ |
{ |
1487 |
XFreeCursor(g_display, (Cursor) cursor); |
XFreeCursor(g_display, (Cursor) cursor); |
1488 |
} |
} |
1489 |
|
|
1490 |
|
void |
1491 |
|
ui_set_null_cursor(void) |
1492 |
|
{ |
1493 |
|
ui_set_cursor(g_null_cursor); |
1494 |
|
} |
1495 |
|
|
1496 |
#define MAKE_XCOLOR(xc,c) \ |
#define MAKE_XCOLOR(xc,c) \ |
1497 |
(xc)->red = ((c)->red << 8) | (c)->red; \ |
(xc)->red = ((c)->red << 8) | (c)->red; \ |
1498 |
(xc)->green = ((c)->green << 8) | (c)->green; \ |
(xc)->green = ((c)->green << 8) | (c)->green; \ |