25 |
#define XK_MISCELLANY |
#define XK_MISCELLANY |
26 |
#include <X11/keysymdef.h> |
#include <X11/keysymdef.h> |
27 |
#include "rdesktop.h" |
#include "rdesktop.h" |
28 |
|
#include "scancodes.h" |
29 |
|
|
30 |
extern int width; |
extern int width; |
31 |
extern int height; |
extern int height; |
32 |
extern BOOL sendmotion; |
extern BOOL sendmotion; |
33 |
extern BOOL fullscreen; |
extern BOOL fullscreen; |
34 |
|
extern BOOL grab_keyboard; |
35 |
|
extern char title[]; |
36 |
|
|
37 |
Display *display = NULL; |
Display *display; |
38 |
static int x_socket; |
static int x_socket; |
39 |
|
static Screen *screen; |
40 |
static Window wnd; |
static Window wnd; |
41 |
static GC gc; |
static GC gc; |
42 |
static Visual *visual; |
static Visual *visual; |
61 |
/* colour maps */ |
/* colour maps */ |
62 |
static BOOL owncolmap; |
static BOOL owncolmap; |
63 |
static Colormap xcolmap; |
static Colormap xcolmap; |
|
static uint32 white; |
|
64 |
static uint32 *colmap; |
static uint32 *colmap; |
|
static XIM IM = NULL; |
|
|
static XIC IC = NULL; |
|
65 |
|
|
66 |
/* Compose support */ |
/* Compose support */ |
67 |
BOOL enable_compose = False; |
BOOL enable_compose = False; |
68 |
|
static XIM IM = NULL; |
69 |
|
static XIC IC = NULL; |
70 |
|
|
71 |
|
/* toggle fullscreen globals */ |
72 |
|
static unsigned long input_mask; |
73 |
|
|
74 |
#define TRANSLATE(col) ( owncolmap ? col : translate_colour(colmap[col]) ) |
#define TRANSLATE(col) ( owncolmap ? col : translate_colour(colmap[col]) ) |
75 |
#define SET_FOREGROUND(col) XSetForeground(display, gc, TRANSLATE(col)); |
#define SET_FOREGROUND(col) XSetForeground(display, gc, TRANSLATE(col)); |
221 |
It seems to work alright anyway, though. */ |
It seems to work alright anyway, though. */ |
222 |
if (IC != NULL) |
if (IC != NULL) |
223 |
{ |
{ |
224 |
if (XGetICValues(IC, XNFilterEvents, &filtered_events, NULL) |
if (XGetICValues(IC, XNFilterEvents, &filtered_events, NULL) != NULL) |
|
!= NULL) |
|
225 |
{ |
{ |
226 |
error("Failed to obtain XNFilterEvents value from IC\n"); |
error("Failed to obtain XNFilterEvents value from IC\n"); |
227 |
filtered_events = 0; |
filtered_events = 0; |
244 |
} |
} |
245 |
} |
} |
246 |
|
|
247 |
|
BOOL |
248 |
|
get_key_state(int keysym) |
249 |
|
{ |
250 |
|
int keysymMask = 0, modifierpos, key; |
251 |
|
Window wDummy1, wDummy2; |
252 |
|
int iDummy3, iDummy4, iDummy5, iDummy6; |
253 |
|
unsigned int current_state; |
254 |
|
int offset; |
255 |
|
|
256 |
|
XModifierKeymap *map = XGetModifierMapping(display); |
257 |
|
KeyCode keycode = XKeysymToKeycode(display, keysym); |
258 |
|
|
259 |
|
if (keycode == NoSymbol) |
260 |
|
return False; |
261 |
|
|
262 |
|
for (modifierpos = 0; modifierpos < 8; modifierpos++) |
263 |
|
{ |
264 |
|
offset = map->max_keypermod * modifierpos; |
265 |
|
|
266 |
|
for (key = 0; key < map->max_keypermod; key++) |
267 |
|
{ |
268 |
|
if (map->modifiermap[offset + key] == keycode) |
269 |
|
keysymMask = 1 << modifierpos; |
270 |
|
} |
271 |
|
} |
272 |
|
|
273 |
|
XQueryPointer(display, DefaultRootWindow(display), &wDummy1, |
274 |
|
&wDummy2, &iDummy3, &iDummy4, &iDummy5, &iDummy6, ¤t_state); |
275 |
|
|
276 |
|
XFreeModifiermap(map); |
277 |
|
|
278 |
|
return (current_state & keysymMask) ? True : False; |
279 |
|
} |
280 |
|
|
281 |
|
static void |
282 |
|
xwin_map_window() |
283 |
|
{ |
284 |
|
XEvent xevent; |
285 |
|
|
286 |
|
XMapWindow(display, wnd); |
287 |
|
|
288 |
|
/* wait for VisibilityChange */ |
289 |
|
XMaskEvent(display, VisibilityChangeMask, &xevent); |
290 |
|
|
291 |
|
if (fullscreen) |
292 |
|
XSetInputFocus(display, wnd, RevertToPointerRoot, CurrentTime); |
293 |
|
} |
294 |
|
|
295 |
BOOL |
BOOL |
296 |
ui_create_window(char *title) |
ui_init() |
297 |
{ |
{ |
|
XSetWindowAttributes attribs; |
|
|
XClassHint *classhints; |
|
|
XSizeHints *sizehints; |
|
|
unsigned long input_mask; |
|
298 |
XPixmapFormatValues *pfm; |
XPixmapFormatValues *pfm; |
|
Screen *screen; |
|
299 |
uint16 test; |
uint16 test; |
300 |
int i; |
int i; |
301 |
|
|
302 |
display = XOpenDisplay(NULL); |
display = XOpenDisplay(NULL); |
|
|
|
303 |
if (display == NULL) |
if (display == NULL) |
304 |
{ |
{ |
305 |
error("Failed to open display\n"); |
error("Failed to open display\n"); |
318 |
desirable, e.g. 24 bits->32 bits. */ |
desirable, e.g. 24 bits->32 bits. */ |
319 |
while (i--) |
while (i--) |
320 |
{ |
{ |
321 |
if ((pfm[i].depth == depth) |
if ((pfm[i].depth == depth) && (pfm[i].bits_per_pixel > bpp)) |
|
&& (pfm[i].bits_per_pixel > bpp)) |
|
322 |
{ |
{ |
323 |
bpp = pfm[i].bits_per_pixel; |
bpp = pfm[i].bits_per_pixel; |
324 |
} |
} |
338 |
else |
else |
339 |
xcolmap = DefaultColormapOfScreen(screen); |
xcolmap = DefaultColormapOfScreen(screen); |
340 |
|
|
341 |
|
if (DoesBackingStore(screen) == NotUseful) |
342 |
|
ownbackstore = True; |
343 |
|
|
344 |
test = 1; |
test = 1; |
345 |
host_be = !(BOOL) (*(uint8 *) (&test)); |
host_be = !(BOOL) (*(uint8 *) (&test)); |
346 |
xserver_be = (ImageByteOrder(display) == MSBFirst); |
xserver_be = (ImageByteOrder(display) == MSBFirst); |
347 |
|
|
|
white = WhitePixelOfScreen(screen); |
|
|
attribs.background_pixel = BlackPixelOfScreen(screen); |
|
|
attribs.backing_store = DoesBackingStore(screen); |
|
|
|
|
|
if (attribs.backing_store == NotUseful) |
|
|
ownbackstore = True; |
|
|
|
|
348 |
if (fullscreen) |
if (fullscreen) |
349 |
{ |
{ |
|
attribs.override_redirect = True; |
|
350 |
width = WidthOfScreen(screen); |
width = WidthOfScreen(screen); |
351 |
height = HeightOfScreen(screen); |
height = HeightOfScreen(screen); |
352 |
} |
} |
|
else |
|
|
{ |
|
|
attribs.override_redirect = False; |
|
|
} |
|
353 |
|
|
354 |
width = (width + 3) & ~3; /* make width a multiple of 32 bits */ |
xkeymap_init(); |
355 |
|
return True; |
356 |
|
} |
357 |
|
|
358 |
wnd = XCreateWindow(display, RootWindowOfScreen(screen), |
BOOL |
359 |
0, 0, width, height, 0, CopyFromParent, |
ui_create_window() |
360 |
InputOutput, CopyFromParent, |
{ |
361 |
CWBackingStore | CWBackPixel | CWOverrideRedirect, |
XSetWindowAttributes attribs; |
362 |
&attribs); |
XClassHint *classhints; |
363 |
|
XSizeHints *sizehints; |
364 |
|
XEvent xevent; |
365 |
|
|
366 |
|
attribs.background_pixel = BlackPixelOfScreen(screen); |
367 |
|
attribs.backing_store = ownbackstore ? NotUseful : Always; |
368 |
|
attribs.override_redirect = fullscreen; |
369 |
|
wnd = XCreateWindow(display, RootWindowOfScreen(screen), 0, 0, width, height, |
370 |
|
0, CopyFromParent, InputOutput, CopyFromParent, |
371 |
|
CWBackPixel | CWBackingStore | CWOverrideRedirect, &attribs); |
372 |
|
|
373 |
|
if (ownbackstore) |
374 |
|
backstore = XCreatePixmap(display, wnd, width, height, depth); |
375 |
|
|
376 |
XStoreName(display, wnd, title); |
XStoreName(display, wnd, title); |
377 |
|
|
393 |
XFree(sizehints); |
XFree(sizehints); |
394 |
} |
} |
395 |
|
|
396 |
xkeymap_init2(); |
input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | |
397 |
|
VisibilityChangeMask | FocusChangeMask; |
398 |
|
|
399 |
input_mask = |
if (grab_keyboard) |
400 |
KeyPressMask | KeyReleaseMask | ButtonPressMask | |
input_mask |= EnterWindowMask | LeaveWindowMask; |
|
ButtonReleaseMask | EnterWindowMask | LeaveWindowMask; |
|
401 |
if (sendmotion) |
if (sendmotion) |
402 |
input_mask |= PointerMotionMask; |
input_mask |= PointerMotionMask; |
|
|
|
403 |
if (ownbackstore) |
if (ownbackstore) |
404 |
input_mask |= ExposureMask; |
input_mask |= ExposureMask; |
|
|
|
405 |
if (enable_compose) |
if (enable_compose) |
406 |
input_mask |= init_inputmethod(); |
input_mask |= init_inputmethod(); |
407 |
|
|
408 |
XSelectInput(display, wnd, input_mask); |
XSelectInput(display, wnd, input_mask); |
409 |
|
|
410 |
gc = XCreateGC(display, wnd, 0, NULL); |
xwin_map_window(); |
|
|
|
|
if (ownbackstore) |
|
|
backstore = XCreatePixmap(display, wnd, width, height, depth); |
|
411 |
|
|
412 |
XMapWindow(display, wnd); |
/* clear the window so that cached data is not seen */ |
413 |
|
gc = XCreateGC(display, wnd, 0, NULL); |
414 |
|
XSetForeground(display, gc, 0); |
415 |
|
FILL_RECTANGLE(0, 0, width, height); |
416 |
|
|
417 |
return True; |
return True; |
418 |
} |
} |
433 |
} |
} |
434 |
|
|
435 |
static void |
static void |
436 |
xwin_process_events() |
xwin_reset_keys() |
437 |
|
{ |
438 |
|
/* reset keys */ |
439 |
|
uint32 ev_time; |
440 |
|
ev_time = time(NULL); |
441 |
|
rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LCTRL); |
442 |
|
rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LALT); |
443 |
|
rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_LSHIFT); |
444 |
|
rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RCTRL); |
445 |
|
rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RALT); |
446 |
|
rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_RSHIFT); |
447 |
|
} |
448 |
|
|
449 |
|
void |
450 |
|
xwin_toggle_fullscreen() |
451 |
{ |
{ |
452 |
XEvent xevent; |
XEvent xevent; |
453 |
|
XSetWindowAttributes attribs; |
454 |
|
int newwidth, newheight; |
455 |
|
|
456 |
|
fullscreen = !fullscreen; |
457 |
|
newwidth = fullscreen ? WidthOfScreen(screen) : width; |
458 |
|
newheight = fullscreen ? HeightOfScreen(screen) : height; |
459 |
|
|
460 |
|
XUnmapWindow(display, wnd); |
461 |
|
attribs.override_redirect = fullscreen; |
462 |
|
XChangeWindowAttributes(display, wnd, CWOverrideRedirect, &attribs); |
463 |
|
XResizeWindow(display, wnd, newwidth, newheight); |
464 |
|
xwin_map_window(); |
465 |
|
} |
466 |
|
|
467 |
|
/* Process all events in Xlib queue */ |
468 |
|
static void |
469 |
|
xwin_process_events() |
470 |
|
{ |
471 |
|
XEvent xevent; |
472 |
KeySym keysym; |
KeySym keysym; |
473 |
uint16 button, flags; |
uint16 button, flags; |
474 |
uint32 ev_time; |
uint32 ev_time; |
477 |
char str[256]; |
char str[256]; |
478 |
Status status; |
Status status; |
479 |
|
|
480 |
/* Refresh keyboard mapping if it has changed. This is important for |
while (XPending(display) > 0) |
|
Xvnc, since it allocates keycodes dynamically */ |
|
|
if (XCheckTypedEvent(display, MappingNotify, &xevent)) |
|
481 |
{ |
{ |
482 |
if (xevent.xmapping.request == MappingKeyboard |
XNextEvent(display, &xevent); |
|
|| xevent.xmapping.request == MappingModifier) |
|
|
XRefreshKeyboardMapping(&xevent.xmapping); |
|
|
} |
|
483 |
|
|
|
while (XCheckMaskEvent(display, ~0, &xevent)) |
|
|
{ |
|
484 |
if (enable_compose && (XFilterEvent(&xevent, None) == True)) |
if (enable_compose && (XFilterEvent(&xevent, None) == True)) |
485 |
{ |
{ |
486 |
DEBUG_KBD("Filtering event\n"); |
DEBUG_KBD(("Filtering event\n")); |
487 |
continue; |
continue; |
488 |
} |
} |
489 |
|
|
498 |
{ |
{ |
499 |
XmbLookupString(IC, |
XmbLookupString(IC, |
500 |
(XKeyPressedEvent *) & |
(XKeyPressedEvent *) & |
501 |
xevent, str, |
xevent, str, sizeof(str), &keysym, &status); |
502 |
sizeof(str), &keysym, |
if (!((status == XLookupKeySym) || (status == XLookupBoth))) |
|
&status); |
|
|
if (! |
|
|
((status == XLookupKeySym) |
|
|
|| (status == XLookupBoth))) |
|
503 |
{ |
{ |
504 |
error("XmbLookupString failed with status 0x%x\n", status); |
error("XmbLookupString failed with status 0x%x\n", |
505 |
|
status); |
506 |
break; |
break; |
507 |
} |
} |
508 |
} |
} |
509 |
else |
else |
510 |
{ |
{ |
511 |
/* Plain old XLookupString */ |
/* Plain old XLookupString */ |
512 |
DEBUG_KBD |
DEBUG_KBD(("No input context, using XLookupString\n")); |
|
("No input context, using XLookupString\n"); |
|
513 |
XLookupString((XKeyEvent *) & xevent, |
XLookupString((XKeyEvent *) & xevent, |
514 |
str, sizeof(str), |
str, sizeof(str), &keysym, NULL); |
|
&keysym, NULL); |
|
515 |
} |
} |
516 |
|
|
517 |
ksname = get_ksname(keysym); |
ksname = get_ksname(keysym); |
518 |
DEBUG_KBD |
DEBUG_KBD(("\nKeyPress for (keysym 0x%lx, %s)\n", keysym, ksname)); |
|
("\nKeyPress for (keysym 0x%lx, %s)\n", |
|
|
keysym, ksname); |
|
519 |
|
|
520 |
if (inhibit_key(keysym)) |
if (handle_special_keys(keysym, ev_time, True)) |
|
{ |
|
|
DEBUG_KBD("Inhibiting key\n"); |
|
521 |
break; |
break; |
|
} |
|
522 |
|
|
523 |
tr = xkeymap_translate_key(keysym, |
tr = xkeymap_translate_key(keysym, |
524 |
xevent.xkey. |
xevent.xkey.keycode, xevent.xkey.state); |
|
keycode, |
|
|
xevent.xkey.state); |
|
|
|
|
|
ensure_remote_modifiers(ev_time, tr); |
|
525 |
|
|
526 |
if (tr.scancode == 0) |
if (tr.scancode == 0) |
527 |
break; |
break; |
528 |
|
|
529 |
rdp_send_scancode(ev_time, RDP_KEYPRESS, |
ensure_remote_modifiers(ev_time, tr); |
530 |
tr.scancode); |
|
531 |
|
rdp_send_scancode(ev_time, RDP_KEYPRESS, tr.scancode); |
532 |
break; |
break; |
533 |
case KeyRelease: |
case KeyRelease: |
534 |
XLookupString((XKeyEvent *) & xevent, str, |
XLookupString((XKeyEvent *) & xevent, str, |
535 |
sizeof(str), &keysym, NULL); |
sizeof(str), &keysym, NULL); |
536 |
|
|
537 |
ksname = get_ksname(keysym); |
ksname = get_ksname(keysym); |
538 |
DEBUG_KBD |
DEBUG_KBD(("\nKeyRelease for (keysym 0x%lx, %s)\n", keysym, |
539 |
("\nKeyRelease for (keysym 0x%lx, %s)\n", |
ksname)); |
|
keysym, ksname); |
|
540 |
|
|
541 |
if (inhibit_key(keysym)) |
if (handle_special_keys(keysym, ev_time, False)) |
542 |
break; |
break; |
543 |
|
|
544 |
tr = xkeymap_translate_key(keysym, |
tr = xkeymap_translate_key(keysym, |
545 |
xevent.xkey. |
xevent.xkey.keycode, xevent.xkey.state); |
|
keycode, |
|
|
xevent.xkey.state); |
|
546 |
|
|
547 |
if (tr.scancode == 0) |
if (tr.scancode == 0) |
548 |
break; |
break; |
549 |
|
|
550 |
rdp_send_scancode(ev_time, RDP_KEYRELEASE, |
rdp_send_scancode(ev_time, RDP_KEYRELEASE, tr.scancode); |
|
tr.scancode); |
|
551 |
break; |
break; |
552 |
|
|
553 |
case ButtonPress: |
case ButtonPress: |
555 |
/* fall through */ |
/* fall through */ |
556 |
|
|
557 |
case ButtonRelease: |
case ButtonRelease: |
558 |
button = xkeymap_translate_button(xevent. |
button = xkeymap_translate_button(xevent.xbutton.button); |
|
xbutton. |
|
|
button); |
|
559 |
if (button == 0) |
if (button == 0) |
560 |
break; |
break; |
561 |
|
|
562 |
rdp_send_input(ev_time, RDP_INPUT_MOUSE, |
rdp_send_input(ev_time, RDP_INPUT_MOUSE, |
563 |
flags | button, |
flags | button, xevent.xbutton.x, xevent.xbutton.y); |
|
xevent.xbutton.x, |
|
|
xevent.xbutton.y); |
|
564 |
break; |
break; |
565 |
|
|
566 |
case MotionNotify: |
case MotionNotify: |
567 |
rdp_send_input(ev_time, RDP_INPUT_MOUSE, |
rdp_send_input(ev_time, RDP_INPUT_MOUSE, |
568 |
MOUSE_FLAG_MOVE, |
MOUSE_FLAG_MOVE, xevent.xmotion.x, xevent.xmotion.y); |
|
xevent.xmotion.x, |
|
|
xevent.xmotion.y); |
|
569 |
break; |
break; |
570 |
|
|
571 |
|
case FocusIn: |
572 |
|
/* fall through */ |
573 |
case EnterNotify: |
case EnterNotify: |
574 |
XGrabKeyboard(display, wnd, True, |
if (grab_keyboard) |
575 |
GrabModeAsync, GrabModeAsync, |
XGrabKeyboard(display, wnd, True, |
576 |
CurrentTime); |
GrabModeAsync, GrabModeAsync, CurrentTime); |
577 |
break; |
break; |
578 |
|
|
579 |
|
case FocusOut: |
580 |
|
xwin_reset_keys(); |
581 |
|
/* fall through */ |
582 |
case LeaveNotify: |
case LeaveNotify: |
583 |
XUngrabKeyboard(display, CurrentTime); |
if (grab_keyboard) |
584 |
|
XUngrabKeyboard(display, CurrentTime); |
585 |
break; |
break; |
586 |
|
|
587 |
case Expose: |
case Expose: |
591 |
xevent.xexpose.height, |
xevent.xexpose.height, |
592 |
xevent.xexpose.x, xevent.xexpose.y); |
xevent.xexpose.x, xevent.xexpose.y); |
593 |
break; |
break; |
594 |
|
|
595 |
|
case MappingNotify: |
596 |
|
/* Refresh keyboard mapping if it has changed. This is important for |
597 |
|
Xvnc, since it allocates keycodes dynamically */ |
598 |
|
if (xevent.xmapping.request == MappingKeyboard |
599 |
|
|| xevent.xmapping.request == MappingModifier) |
600 |
|
XRefreshKeyboardMapping(&xevent.xmapping); |
601 |
|
break; |
602 |
|
|
603 |
} |
} |
604 |
} |
} |
605 |
} |
} |
614 |
|
|
615 |
while (True) |
while (True) |
616 |
{ |
{ |
617 |
|
/* Process any events already waiting */ |
618 |
|
xwin_process_events(); |
619 |
|
|
620 |
FD_ZERO(&rfds); |
FD_ZERO(&rfds); |
621 |
FD_SET(rdp_socket, &rfds); |
FD_SET(rdp_socket, &rfds); |
622 |
if (display != NULL) |
FD_SET(x_socket, &rfds); |
|
{ |
|
|
FD_SET(x_socket, &rfds); |
|
|
XFlush(display); |
|
|
} |
|
623 |
|
|
624 |
switch (select(n, &rfds, NULL, NULL, NULL)) |
switch (select(n, &rfds, NULL, NULL, NULL)) |
625 |
{ |
{ |
630 |
continue; |
continue; |
631 |
} |
} |
632 |
|
|
|
if (FD_ISSET(x_socket, &rfds)) |
|
|
xwin_process_events(); |
|
|
|
|
633 |
if (FD_ISSET(rdp_socket, &rfds)) |
if (FD_ISSET(rdp_socket, &rfds)) |
634 |
return; |
return; |
635 |
} |
} |
650 |
|
|
651 |
tdata = (owncolmap ? data : translate_image(width, height, data)); |
tdata = (owncolmap ? data : translate_image(width, height, data)); |
652 |
bitmap = XCreatePixmap(display, wnd, width, height, depth); |
bitmap = XCreatePixmap(display, wnd, width, height, depth); |
653 |
image = XCreateImage(display, visual, depth, ZPixmap, 0, (char *)tdata, |
image = XCreateImage(display, visual, depth, ZPixmap, 0, |
654 |
width, height, 8, 0); |
(char *) tdata, width, height, 8, 0); |
655 |
|
|
656 |
XPutImage(display, bitmap, gc, image, 0, 0, 0, 0, width, height); |
XPutImage(display, bitmap, gc, image, 0, 0, 0, 0, width, height); |
657 |
|
|
662 |
} |
} |
663 |
|
|
664 |
void |
void |
665 |
ui_paint_bitmap(int x, int y, int cx, int cy, int width, int height, |
ui_paint_bitmap(int x, int y, int cx, int cy, int width, int height, uint8 * data) |
|
uint8 * data) |
|
666 |
{ |
{ |
667 |
XImage *image; |
XImage *image; |
668 |
uint8 *tdata; |
uint8 *tdata; |
669 |
|
|
670 |
tdata = (owncolmap ? data : translate_image(width, height, data)); |
tdata = (owncolmap ? data : translate_image(width, height, data)); |
671 |
image = XCreateImage(display, visual, depth, ZPixmap, 0, (char *)tdata, |
image = XCreateImage(display, visual, depth, ZPixmap, 0, |
672 |
width, height, 8, 0); |
(char *) tdata, width, height, 8, 0); |
673 |
|
|
674 |
if (ownbackstore) |
if (ownbackstore) |
675 |
{ |
{ |
705 |
bitmap = XCreatePixmap(display, wnd, width, height, 1); |
bitmap = XCreatePixmap(display, wnd, width, height, 1); |
706 |
gc = XCreateGC(display, bitmap, 0, NULL); |
gc = XCreateGC(display, bitmap, 0, NULL); |
707 |
|
|
708 |
image = XCreateImage(display, visual, 1, ZPixmap, 0, (char *)data, |
image = XCreateImage(display, visual, 1, ZPixmap, 0, (char *) data, |
709 |
width, height, 8, scanline); |
width, height, 8, scanline); |
710 |
image->byte_order = MSBFirst; |
image->byte_order = MSBFirst; |
711 |
image->bitmap_bit_order = MSBFirst; |
image->bitmap_bit_order = MSBFirst; |
853 |
if (XAllocColor(display, xcolmap, &xentry) != 0) |
if (XAllocColor(display, xcolmap, &xentry) != 0) |
854 |
colour = xentry.pixel; |
colour = xentry.pixel; |
855 |
else |
else |
856 |
colour = white; |
colour = WhitePixelOfScreen(screen); |
857 |
|
|
858 |
/* byte swap here to make translate_image faster */ |
/* byte swap here to make translate_image faster */ |
859 |
map[i] = translate_colour(colour); |
map[i] = translate_colour(colour); |
946 |
SET_BACKGROUND(fgcolour); |
SET_BACKGROUND(fgcolour); |
947 |
XSetFillStyle(display, gc, FillOpaqueStippled); |
XSetFillStyle(display, gc, FillOpaqueStippled); |
948 |
XSetStipple(display, gc, fill); |
XSetStipple(display, gc, fill); |
949 |
XSetTSOrigin(display, gc, brush->xorigin, |
XSetTSOrigin(display, gc, brush->xorigin, brush->yorigin); |
|
brush->yorigin); |
|
950 |
|
|
951 |
FILL_RECTANGLE(x, y, cx, cy); |
FILL_RECTANGLE(x, y, cx, cy); |
952 |
|
|
953 |
XSetFillStyle(display, gc, FillSolid); |
XSetFillStyle(display, gc, FillSolid); |
954 |
|
XSetTSOrigin(display, gc, 0, 0); |
955 |
ui_destroy_glyph((HGLYPH) fill); |
ui_destroy_glyph((HGLYPH) fill); |
956 |
break; |
break; |
957 |
|
|
970 |
SET_FUNCTION(opcode); |
SET_FUNCTION(opcode); |
971 |
XCopyArea(display, wnd, wnd, gc, srcx, srcy, cx, cy, x, y); |
XCopyArea(display, wnd, wnd, gc, srcx, srcy, cx, cy, x, y); |
972 |
if (ownbackstore) |
if (ownbackstore) |
973 |
XCopyArea(display, backstore, backstore, gc, srcx, srcy, cx, |
XCopyArea(display, backstore, backstore, gc, srcx, srcy, cx, cy, x, y); |
|
cy, x, y); |
|
974 |
RESET_FUNCTION(opcode); |
RESET_FUNCTION(opcode); |
975 |
} |
} |
976 |
|
|
982 |
SET_FUNCTION(opcode); |
SET_FUNCTION(opcode); |
983 |
XCopyArea(display, (Pixmap) src, wnd, gc, srcx, srcy, cx, cy, x, y); |
XCopyArea(display, (Pixmap) src, wnd, gc, srcx, srcy, cx, cy, x, y); |
984 |
if (ownbackstore) |
if (ownbackstore) |
985 |
XCopyArea(display, (Pixmap) src, backstore, gc, srcx, srcy, |
XCopyArea(display, (Pixmap) src, backstore, gc, srcx, srcy, cx, cy, x, y); |
|
cx, cy, x, y); |
|
986 |
RESET_FUNCTION(opcode); |
RESET_FUNCTION(opcode); |
987 |
} |
} |
988 |
|
|
999 |
{ |
{ |
1000 |
case 0x69: /* PDSxxn */ |
case 0x69: /* PDSxxn */ |
1001 |
ui_memblt(ROP2_XOR, x, y, cx, cy, src, srcx, srcy); |
ui_memblt(ROP2_XOR, x, y, cx, cy, src, srcx, srcy); |
1002 |
ui_patblt(ROP2_NXOR, x, y, cx, cy, brush, bgcolour, |
ui_patblt(ROP2_NXOR, x, y, cx, cy, brush, bgcolour, fgcolour); |
|
fgcolour); |
|
1003 |
break; |
break; |
1004 |
|
|
1005 |
case 0xb8: /* PSDPxax */ |
case 0xb8: /* PSDPxax */ |
1006 |
ui_patblt(ROP2_XOR, x, y, cx, cy, brush, bgcolour, |
ui_patblt(ROP2_XOR, x, y, cx, cy, brush, bgcolour, fgcolour); |
|
fgcolour); |
|
1007 |
ui_memblt(ROP2_AND, x, y, cx, cy, src, srcx, srcy); |
ui_memblt(ROP2_AND, x, y, cx, cy, src, srcx, srcy); |
1008 |
ui_patblt(ROP2_XOR, x, y, cx, cy, brush, bgcolour, |
ui_patblt(ROP2_XOR, x, y, cx, cy, brush, bgcolour, fgcolour); |
|
fgcolour); |
|
1009 |
break; |
break; |
1010 |
|
|
1011 |
case 0xc0: /* PSa */ |
case 0xc0: /* PSa */ |
1012 |
ui_memblt(ROP2_COPY, x, y, cx, cy, src, srcx, srcy); |
ui_memblt(ROP2_COPY, x, y, cx, cy, src, srcx, srcy); |
1013 |
ui_patblt(ROP2_AND, x, y, cx, cy, brush, bgcolour, |
ui_patblt(ROP2_AND, x, y, cx, cy, brush, bgcolour, fgcolour); |
|
fgcolour); |
|
1014 |
break; |
break; |
1015 |
|
|
1016 |
default: |
default: |
1051 |
SET_BACKGROUND(bgcolour); |
SET_BACKGROUND(bgcolour); |
1052 |
|
|
1053 |
XSetFillStyle(display, gc, |
XSetFillStyle(display, gc, |
1054 |
(mixmode == |
(mixmode == MIX_TRANSPARENT) ? FillStippled : FillOpaqueStippled); |
|
MIX_TRANSPARENT) ? FillStippled : FillOpaqueStippled); |
|
1055 |
XSetStipple(display, gc, (Pixmap) glyph); |
XSetStipple(display, gc, (Pixmap) glyph); |
1056 |
XSetTSOrigin(display, gc, x, y); |
XSetTSOrigin(display, gc, x, y); |
1057 |
|
|
1121 |
{ |
{ |
1122 |
case 0xff: |
case 0xff: |
1123 |
if (i + 2 < length) |
if (i + 2 < length) |
1124 |
cache_put_text(text[i + 1], text, |
cache_put_text(text[i + 1], text, text[i + 2]); |
|
text[i + 2]); |
|
1125 |
else |
else |
1126 |
{ |
{ |
1127 |
error("this shouldn't be happening\n"); |
error("this shouldn't be happening\n"); |
1138 |
if (entry != NULL) |
if (entry != NULL) |
1139 |
{ |
{ |
1140 |
if ((((uint8 *) (entry->data))[1] == |
if ((((uint8 *) (entry->data))[1] == |
1141 |
0) |
0) && (!(flags & TEXT2_IMPLICIT_X))) |
|
&& (!(flags & TEXT2_IMPLICIT_X))) |
|
1142 |
{ |
{ |
1143 |
if (flags & TEXT2_VERTICAL) |
if (flags & TEXT2_VERTICAL) |
1144 |
y += text[i + 2]; |
y += text[i + 2]; |
1154 |
text = &(text[i]); |
text = &(text[i]); |
1155 |
i = 0; |
i = 0; |
1156 |
for (j = 0; j < entry->size; j++) |
for (j = 0; j < entry->size; j++) |
1157 |
DO_GLYPH(((uint8 *) (entry-> |
DO_GLYPH(((uint8 *) (entry->data)), j); |
|
data)), |
|
|
j); |
|
1158 |
} |
} |
1159 |
break; |
break; |
1160 |
|
|
1176 |
|
|
1177 |
if (ownbackstore) |
if (ownbackstore) |
1178 |
{ |
{ |
1179 |
image = XGetImage(display, backstore, x, y, cx, cy, AllPlanes, |
image = XGetImage(display, backstore, x, y, cx, cy, AllPlanes, ZPixmap); |
|
ZPixmap); |
|
1180 |
} |
} |
1181 |
else |
else |
1182 |
{ |
{ |
1183 |
pix = XCreatePixmap(display, wnd, cx, cy, depth); |
pix = XCreatePixmap(display, wnd, cx, cy, depth); |
1184 |
XCopyArea(display, wnd, pix, gc, x, y, cx, cy, 0, 0); |
XCopyArea(display, wnd, pix, gc, x, y, cx, cy, 0, 0); |
1185 |
image = XGetImage(display, pix, 0, 0, cx, cy, AllPlanes, |
image = XGetImage(display, pix, 0, 0, cx, cy, AllPlanes, ZPixmap); |
|
ZPixmap); |
|
1186 |
XFreePixmap(display, pix); |
XFreePixmap(display, pix); |
1187 |
} |
} |
1188 |
|
|
1189 |
offset *= bpp / 8; |
offset *= bpp / 8; |
1190 |
cache_put_desktop(offset, cx, cy, image->bytes_per_line, bpp / 8, |
cache_put_desktop(offset, cx, cy, image->bytes_per_line, bpp / 8, (uint8 *) image->data); |
|
(uint8 *) image->data); |
|
1191 |
|
|
1192 |
XDestroyImage(image); |
XDestroyImage(image); |
1193 |
} |
} |
1203 |
if (data == NULL) |
if (data == NULL) |
1204 |
return; |
return; |
1205 |
|
|
1206 |
image = XCreateImage(display, visual, depth, ZPixmap, 0, (char *)data, |
image = XCreateImage(display, visual, depth, ZPixmap, 0, |
1207 |
cx, cy, BitmapPad(display), cx * bpp / 8); |
(char *) data, cx, cy, BitmapPad(display), cx * bpp / 8); |
1208 |
|
|
1209 |
if (ownbackstore) |
if (ownbackstore) |
1210 |
{ |
{ |