1 |
/* |
/* |
2 |
rdesktop: A Remote Desktop Protocol client. |
rdesktop: A Remote Desktop Protocol client. |
3 |
User interface services - X-Windows |
User interface services - X Window System |
4 |
Copyright (C) Matthew Chapman 1999-2001 |
Copyright (C) Matthew Chapman 1999-2001 |
5 |
|
|
6 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
21 |
#include <X11/Xlib.h> |
#include <X11/Xlib.h> |
22 |
#include <X11/Xutil.h> |
#include <X11/Xutil.h> |
23 |
#include <time.h> |
#include <time.h> |
24 |
|
#include <errno.h> |
25 |
#include "rdesktop.h" |
#include "rdesktop.h" |
26 |
|
|
27 |
|
extern char keymapname[16]; |
28 |
|
extern int keylayout; |
29 |
extern int width; |
extern int width; |
30 |
extern int height; |
extern int height; |
31 |
extern BOOL sendmotion; |
extern BOOL sendmotion; |
32 |
extern BOOL fullscreen; |
extern BOOL fullscreen; |
33 |
|
|
34 |
static Display *display; |
static Display *display; |
35 |
|
static int x_socket; |
36 |
static Window wnd; |
static Window wnd; |
37 |
static GC gc; |
static GC gc; |
38 |
static Visual *visual; |
static Visual *visual; |
39 |
static int depth; |
static int depth; |
40 |
static int bpp; |
static int bpp; |
|
static BOOL backpixmap; |
|
41 |
|
|
42 |
|
/* endianness */ |
43 |
|
static BOOL host_be; |
44 |
|
static BOOL xserver_be; |
45 |
|
|
46 |
|
/* software backing store */ |
47 |
|
static BOOL ownbackstore; |
48 |
|
static Pixmap backstore; |
49 |
|
|
50 |
|
#define FILL_RECTANGLE(x,y,cx,cy)\ |
51 |
|
{ \ |
52 |
|
XFillRectangle(display, wnd, gc, x, y, cx, cy); \ |
53 |
|
if (ownbackstore) \ |
54 |
|
XFillRectangle(display, backstore, gc, x, y, cx, cy); \ |
55 |
|
} |
56 |
|
|
57 |
|
/* colour maps */ |
58 |
static BOOL owncolmap; |
static BOOL owncolmap; |
59 |
static Colormap xcolmap; |
static Colormap xcolmap; |
60 |
static uint32 white; |
static uint32 white; |
61 |
static uint32 *colmap; |
static uint32 *colmap; |
62 |
|
|
63 |
#define TRANSLATE(col) ( owncolmap ? col : colmap[col] ) |
#define TRANSLATE(col) ( owncolmap ? col : translate_colour(colmap[col]) ) |
64 |
#define SET_FOREGROUND(col) XSetForeground(display, gc, TRANSLATE(col)); |
#define SET_FOREGROUND(col) XSetForeground(display, gc, TRANSLATE(col)); |
65 |
#define SET_BACKGROUND(col) XSetBackground(display, gc, TRANSLATE(col)); |
#define SET_BACKGROUND(col) XSetBackground(display, gc, TRANSLATE(col)); |
66 |
|
|
100 |
*(out++) = (uint16)colmap[*(data++)]; |
*(out++) = (uint16)colmap[*(data++)]; |
101 |
} |
} |
102 |
|
|
103 |
/* XXX endianness */ |
/* little endian - conversion happens when colourmap is built */ |
104 |
static void |
static void |
105 |
translate24(uint8 *data, uint8 *out, uint8 *end) |
translate24(uint8 *data, uint8 *out, uint8 *end) |
106 |
{ |
{ |
123 |
} |
} |
124 |
|
|
125 |
static uint8 * |
static uint8 * |
126 |
translate(int width, int height, uint8 *data) |
translate_image(int width, int height, uint8 *data) |
127 |
{ |
{ |
128 |
int size = width * height * bpp/8; |
int size = width * height * bpp/8; |
129 |
uint8 *out = xmalloc(size); |
uint8 *out = xmalloc(size); |
151 |
return out; |
return out; |
152 |
} |
} |
153 |
|
|
154 |
#define L_ENDIAN |
#define BSWAP16(x) { x = (((x & 0xff) << 8) | (x >> 8)); } |
155 |
int screen_msbfirst = 0; |
#define BSWAP24(x) { x = (((x & 0xff) << 16) | (x >> 16) | ((x >> 8) & 0xff00)); } |
156 |
|
#define BSWAP32(x) { x = (((x & 0xff00ff) << 8) | ((x >> 8) & 0xff00ff)); \ |
157 |
|
x = (x << 16) | (x >> 16); } |
158 |
|
|
159 |
|
static uint32 |
160 |
|
translate_colour(uint32 colour) |
161 |
|
{ |
162 |
|
switch (bpp) |
163 |
|
{ |
164 |
|
case 16: |
165 |
|
if (host_be != xserver_be) |
166 |
|
BSWAP16(colour); |
167 |
|
break; |
168 |
|
|
169 |
|
case 24: |
170 |
|
if (xserver_be) |
171 |
|
BSWAP24(colour); |
172 |
|
break; |
173 |
|
|
174 |
|
case 32: |
175 |
|
if (host_be != xserver_be) |
176 |
|
BSWAP32(colour); |
177 |
|
break; |
178 |
|
} |
179 |
|
|
180 |
|
return colour; |
181 |
|
} |
182 |
|
|
183 |
BOOL |
BOOL |
184 |
ui_create_window(char *title) |
ui_create_window(char *title) |
189 |
unsigned long input_mask; |
unsigned long input_mask; |
190 |
XPixmapFormatValues *pfm; |
XPixmapFormatValues *pfm; |
191 |
Screen *screen; |
Screen *screen; |
192 |
|
uint16 test; |
193 |
int i; |
int i; |
194 |
|
|
|
|
|
195 |
display = XOpenDisplay(NULL); |
display = XOpenDisplay(NULL); |
196 |
if (display == NULL) |
if (display == NULL) |
197 |
{ |
{ |
199 |
return False; |
return False; |
200 |
} |
} |
201 |
|
|
202 |
|
x_socket = ConnectionNumber(display); |
203 |
screen = DefaultScreenOfDisplay(display); |
screen = DefaultScreenOfDisplay(display); |
204 |
visual = DefaultVisualOfScreen(screen); |
visual = DefaultVisualOfScreen(screen); |
205 |
depth = DefaultDepthOfScreen(screen); |
depth = DefaultDepthOfScreen(screen); |
232 |
else |
else |
233 |
xcolmap = DefaultColormapOfScreen(screen); |
xcolmap = DefaultColormapOfScreen(screen); |
234 |
|
|
235 |
|
test = 1; |
236 |
|
host_be = !(BOOL)(*(uint8 *)(&test)); |
237 |
|
xserver_be = (ImageByteOrder(display) == MSBFirst); |
238 |
|
|
239 |
white = WhitePixelOfScreen(screen); |
white = WhitePixelOfScreen(screen); |
240 |
attribs.background_pixel = BlackPixelOfScreen(screen); |
attribs.background_pixel = BlackPixelOfScreen(screen); |
241 |
attribs.backing_store = DoesBackingStore(screen); |
attribs.backing_store = DoesBackingStore(screen); |
242 |
|
|
243 |
if (attribs.backing_store == NotUseful) |
if (attribs.backing_store == NotUseful) |
244 |
backpixmap = True; |
ownbackstore = True; |
245 |
|
|
246 |
if (fullscreen) |
if (fullscreen) |
247 |
{ |
{ |
282 |
XFree(sizehints); |
XFree(sizehints); |
283 |
} |
} |
284 |
|
|
285 |
|
xkeymap_init(display); |
286 |
|
|
287 |
input_mask = KeyPressMask | KeyReleaseMask |
input_mask = KeyPressMask | KeyReleaseMask |
288 |
| ButtonPressMask | ButtonReleaseMask |
| ButtonPressMask | ButtonReleaseMask |
289 |
| EnterWindowMask | LeaveWindowMask; |
| EnterWindowMask | LeaveWindowMask; |
291 |
if (sendmotion) |
if (sendmotion) |
292 |
input_mask |= PointerMotionMask; |
input_mask |= PointerMotionMask; |
293 |
|
|
294 |
|
if (ownbackstore) |
295 |
|
input_mask |= ExposureMask; |
296 |
|
|
297 |
XSelectInput(display, wnd, input_mask); |
XSelectInput(display, wnd, input_mask); |
298 |
gc = XCreateGC(display, wnd, 0, NULL); |
gc = XCreateGC(display, wnd, 0, NULL); |
299 |
|
|
300 |
|
if (ownbackstore) |
301 |
|
backstore = XCreatePixmap(display, wnd, width, height, depth); |
302 |
|
|
303 |
XMapWindow(display, wnd); |
XMapWindow(display, wnd); |
304 |
return True; |
return True; |
305 |
} |
} |
307 |
void |
void |
308 |
ui_destroy_window() |
ui_destroy_window() |
309 |
{ |
{ |
310 |
|
if (ownbackstore) |
311 |
|
XFreePixmap(display, backstore); |
312 |
|
|
313 |
XFreeGC(display, gc); |
XFreeGC(display, gc); |
314 |
XDestroyWindow(display, wnd); |
XDestroyWindow(display, wnd); |
315 |
XCloseDisplay(display); |
XCloseDisplay(display); |
316 |
display = NULL; |
display = NULL; |
317 |
} |
} |
318 |
|
|
319 |
static uint8 |
static void |
320 |
xwin_translate_key(unsigned long key) |
xwin_process_events() |
|
{ |
|
|
DEBUG(("KEY(code=0x%lx)\n", key)); |
|
|
|
|
|
if ((key > 8) && (key <= 0x60)) |
|
|
return (key - 8); |
|
|
|
|
|
switch (key) |
|
|
{ |
|
|
case 0x61: /* home */ |
|
|
return 0x47 | 0x80; |
|
|
case 0x62: /* up arrow */ |
|
|
return 0x48 | 0x80; |
|
|
case 0x63: /* page up */ |
|
|
return 0x49 | 0x80; |
|
|
case 0x64: /* left arrow */ |
|
|
return 0x4b | 0x80; |
|
|
case 0x66: /* right arrow */ |
|
|
return 0x4d | 0x80; |
|
|
case 0x67: /* end */ |
|
|
return 0x4f | 0x80; |
|
|
case 0x68: /* down arrow */ |
|
|
return 0x50 | 0x80; |
|
|
case 0x69: /* page down */ |
|
|
return 0x51 | 0x80; |
|
|
case 0x6a: /* insert */ |
|
|
return 0x52 | 0x80; |
|
|
case 0x6b: /* delete */ |
|
|
return 0x53 | 0x80; |
|
|
case 0x6c: /* keypad enter */ |
|
|
return 0x1c | 0x80; |
|
|
case 0x6d: /* right ctrl */ |
|
|
return 0x1d | 0x80; |
|
|
case 0x6f: /* ctrl - print screen */ |
|
|
return 0x37 | 0x80; |
|
|
case 0x70: /* keypad '/' */ |
|
|
return 0x35 | 0x80; |
|
|
case 0x71: /* right alt */ |
|
|
return 0x38 | 0x80; |
|
|
case 0x72: /* ctrl break */ |
|
|
return 0x46 | 0x80; |
|
|
case 0x73: /* left window key */ |
|
|
return 0xff; /* real scancode is 5b */ |
|
|
case 0x74: /* right window key */ |
|
|
return 0xff; /* real scancode is 5c */ |
|
|
case 0x75: /* menu key */ |
|
|
return 0x5d | 0x80; |
|
|
} |
|
|
|
|
|
return 0; |
|
|
} |
|
|
|
|
|
static uint16 |
|
|
xwin_translate_mouse(unsigned long button) |
|
|
{ |
|
|
switch (button) |
|
|
{ |
|
|
case Button1: /* left */ |
|
|
return MOUSE_FLAG_BUTTON1; |
|
|
case Button2: /* middle */ |
|
|
return MOUSE_FLAG_BUTTON3; |
|
|
case Button3: /* right */ |
|
|
return MOUSE_FLAG_BUTTON2; |
|
|
} |
|
|
|
|
|
return 0; |
|
|
} |
|
|
|
|
|
void |
|
|
ui_process_events() |
|
321 |
{ |
{ |
322 |
XEvent event; |
XEvent event; |
323 |
|
KeySym keysym; |
324 |
uint8 scancode; |
uint8 scancode; |
325 |
uint16 button; |
uint16 button; |
326 |
uint32 ev_time; |
uint32 ev_time; |
328 |
if (display == NULL) |
if (display == NULL) |
329 |
return; |
return; |
330 |
|
|
331 |
while (XCheckWindowEvent(display, wnd, ~0, &event)) |
while (XCheckMaskEvent(display, ~0, &event)) |
332 |
{ |
{ |
333 |
ev_time = time(NULL); |
ev_time = time(NULL); |
334 |
|
|
335 |
switch (event.type) |
switch (event.type) |
336 |
{ |
{ |
337 |
case KeyPress: |
case KeyPress: |
338 |
scancode = xwin_translate_key(event.xkey.keycode); |
keysym = XKeycodeToKeysym(display, event.xkey.keycode, 0); |
339 |
|
scancode = xkeymap_translate_key(keysym, event.xkey.keycode); |
340 |
if (scancode == 0) |
if (scancode == 0) |
341 |
break; |
break; |
342 |
|
|
345 |
break; |
break; |
346 |
|
|
347 |
case KeyRelease: |
case KeyRelease: |
348 |
scancode = xwin_translate_key(event.xkey.keycode); |
keysym = XKeycodeToKeysym(display, event.xkey.keycode, 0); |
349 |
|
scancode = xkeymap_translate_key(keysym, event.xkey.keycode); |
350 |
if (scancode == 0) |
if (scancode == 0) |
351 |
break; |
break; |
352 |
|
|
356 |
break; |
break; |
357 |
|
|
358 |
case ButtonPress: |
case ButtonPress: |
359 |
button = xwin_translate_mouse(event.xbutton.button); |
button = xkeymap_translate_button(event.xbutton.button); |
360 |
if (button == 0) |
if (button == 0) |
361 |
break; |
break; |
362 |
|
|
367 |
break; |
break; |
368 |
|
|
369 |
case ButtonRelease: |
case ButtonRelease: |
370 |
button = xwin_translate_mouse(event.xbutton.button); |
button = xkeymap_translate_button(event.xbutton.button); |
371 |
if (button == 0) |
if (button == 0) |
372 |
break; |
break; |
373 |
|
|
392 |
case LeaveNotify: |
case LeaveNotify: |
393 |
XUngrabKeyboard(display, CurrentTime); |
XUngrabKeyboard(display, CurrentTime); |
394 |
break; |
break; |
395 |
|
|
396 |
|
case Expose: |
397 |
|
XCopyArea(display, backstore, wnd, gc, |
398 |
|
event.xexpose.x, event.xexpose.y, |
399 |
|
event.xexpose.width, event.xexpose.height, |
400 |
|
event.xexpose.x, event.xexpose.y); |
401 |
|
break; |
402 |
} |
} |
403 |
} |
} |
404 |
} |
} |
405 |
|
|
406 |
void |
void |
407 |
|
ui_select(int rdp_socket) |
408 |
|
{ |
409 |
|
int n = (rdp_socket > x_socket) ? rdp_socket+1 : x_socket+1; |
410 |
|
fd_set rfds; |
411 |
|
|
412 |
|
XFlush(display); |
413 |
|
|
414 |
|
FD_ZERO(&rfds); |
415 |
|
|
416 |
|
while (True) |
417 |
|
{ |
418 |
|
FD_ZERO(&rfds); |
419 |
|
FD_SET(rdp_socket, &rfds); |
420 |
|
FD_SET(x_socket, &rfds); |
421 |
|
|
422 |
|
switch (select(n, &rfds, NULL, NULL, NULL)) |
423 |
|
{ |
424 |
|
case -1: |
425 |
|
error("select: %s\n", strerror(errno)); |
426 |
|
|
427 |
|
case 0: |
428 |
|
continue; |
429 |
|
} |
430 |
|
|
431 |
|
if (FD_ISSET(x_socket, &rfds)) |
432 |
|
xwin_process_events(); |
433 |
|
|
434 |
|
if (FD_ISSET(rdp_socket, &rfds)) |
435 |
|
return; |
436 |
|
} |
437 |
|
} |
438 |
|
|
439 |
|
void |
440 |
ui_move_pointer(int x, int y) |
ui_move_pointer(int x, int y) |
441 |
{ |
{ |
442 |
XWarpPointer(display, wnd, wnd, 0, 0, 0, 0, x, y); |
XWarpPointer(display, wnd, wnd, 0, 0, 0, 0, x, y); |
449 |
Pixmap bitmap; |
Pixmap bitmap; |
450 |
uint8 *tdata; |
uint8 *tdata; |
451 |
|
|
452 |
tdata = (owncolmap ? data : translate(width, height, data)); |
tdata = (owncolmap ? data : translate_image(width, height, data)); |
453 |
bitmap = XCreatePixmap(display, wnd, width, height, depth); |
bitmap = XCreatePixmap(display, wnd, width, height, depth); |
454 |
image = XCreateImage(display, visual, depth, ZPixmap, |
image = XCreateImage(display, visual, depth, ZPixmap, |
455 |
0, tdata, width, height, 8, 0); |
0, tdata, width, height, 8, 0); |
469 |
XImage *image; |
XImage *image; |
470 |
uint8 *tdata; |
uint8 *tdata; |
471 |
|
|
472 |
tdata = (owncolmap ? data : translate(width, height, data)); |
tdata = (owncolmap ? data : translate_image(width, height, data)); |
473 |
image = XCreateImage(display, visual, depth, ZPixmap, |
image = XCreateImage(display, visual, depth, ZPixmap, |
474 |
0, tdata, width, height, 8, 0); |
0, tdata, width, height, 8, 0); |
475 |
|
|
476 |
XPutImage(display, wnd, gc, image, 0, 0, x, y, cx, cy); |
if (ownbackstore) |
477 |
|
{ |
478 |
|
XPutImage(display, backstore, gc, image, 0, 0, x, y, cx, cy); |
479 |
|
XCopyArea(display, backstore, wnd, gc, x, y, cx, cy, x, y); |
480 |
|
} |
481 |
|
else |
482 |
|
{ |
483 |
|
XPutImage(display, wnd, gc, image, 0, 0, x, y, cx, cy); |
484 |
|
} |
485 |
|
|
486 |
XFree(image); |
XFree(image); |
487 |
if (!owncolmap) |
if (!owncolmap) |
644 |
{ |
{ |
645 |
uint32 *map = xmalloc(sizeof(*colmap) * ncolours); |
uint32 *map = xmalloc(sizeof(*colmap) * ncolours); |
646 |
XColor xentry; |
XColor xentry; |
647 |
|
uint32 colour; |
648 |
|
|
649 |
for (i = 0; i < ncolours; i++) |
for (i = 0; i < ncolours; i++) |
650 |
{ |
{ |
652 |
MAKE_XCOLOR(&xentry, entry); |
MAKE_XCOLOR(&xentry, entry); |
653 |
|
|
654 |
if (XAllocColor(display, xcolmap, &xentry) != 0) |
if (XAllocColor(display, xcolmap, &xentry) != 0) |
655 |
map[i] = xentry.pixel; |
colour = xentry.pixel; |
656 |
else |
else |
657 |
map[i] = white; |
colour = white; |
658 |
|
|
659 |
|
/* byte swap here to make translate_image faster */ |
660 |
|
map[i] = translate_colour(colour); |
661 |
} |
} |
662 |
|
|
663 |
return map; |
return map; |
717 |
/* dest */ int x, int y, int cx, int cy) |
/* dest */ int x, int y, int cx, int cy) |
718 |
{ |
{ |
719 |
SET_FUNCTION(opcode); |
SET_FUNCTION(opcode); |
720 |
XFillRectangle(display, wnd, gc, x, y, cx, cy); |
FILL_RECTANGLE(x, y, cx, cy); |
721 |
RESET_FUNCTION(opcode); |
RESET_FUNCTION(opcode); |
722 |
} |
} |
723 |
|
|
734 |
{ |
{ |
735 |
case 0: /* Solid */ |
case 0: /* Solid */ |
736 |
SET_FOREGROUND(fgcolour); |
SET_FOREGROUND(fgcolour); |
737 |
XFillRectangle(display, wnd, gc, x, y, cx, cy); |
FILL_RECTANGLE(x, y, cx, cy); |
738 |
break; |
break; |
739 |
|
|
740 |
case 3: /* Pattern */ |
case 3: /* Pattern */ |
746 |
XSetStipple(display, gc, fill); |
XSetStipple(display, gc, fill); |
747 |
XSetTSOrigin(display, gc, brush->xorigin, brush->yorigin); |
XSetTSOrigin(display, gc, brush->xorigin, brush->yorigin); |
748 |
|
|
749 |
XFillRectangle(display, wnd, gc, x, y, cx, cy); |
FILL_RECTANGLE(x, y, cx, cy); |
750 |
|
|
751 |
XSetFillStyle(display, gc, FillSolid); |
XSetFillStyle(display, gc, FillSolid); |
752 |
ui_destroy_glyph((HGLYPH)fill); |
ui_destroy_glyph((HGLYPH)fill); |
766 |
{ |
{ |
767 |
SET_FUNCTION(opcode); |
SET_FUNCTION(opcode); |
768 |
XCopyArea(display, wnd, wnd, gc, srcx, srcy, cx, cy, x, y); |
XCopyArea(display, wnd, wnd, gc, srcx, srcy, cx, cy, x, y); |
769 |
|
if (ownbackstore) |
770 |
|
XCopyArea(display, backstore, backstore, gc, srcx, srcy, |
771 |
|
cx, cy, x, y); |
772 |
RESET_FUNCTION(opcode); |
RESET_FUNCTION(opcode); |
773 |
} |
} |
774 |
|
|
779 |
{ |
{ |
780 |
SET_FUNCTION(opcode); |
SET_FUNCTION(opcode); |
781 |
XCopyArea(display, (Pixmap)src, wnd, gc, srcx, srcy, cx, cy, x, y); |
XCopyArea(display, (Pixmap)src, wnd, gc, srcx, srcy, cx, cy, x, y); |
782 |
|
if (ownbackstore) |
783 |
|
XCopyArea(display, (Pixmap)src, backstore, gc, srcx, srcy, |
784 |
|
cx, cy, x, y); |
785 |
RESET_FUNCTION(opcode); |
RESET_FUNCTION(opcode); |
786 |
} |
} |
787 |
|
|
830 |
SET_FUNCTION(opcode); |
SET_FUNCTION(opcode); |
831 |
SET_FOREGROUND(pen->colour); |
SET_FOREGROUND(pen->colour); |
832 |
XDrawLine(display, wnd, gc, startx, starty, endx, endy); |
XDrawLine(display, wnd, gc, startx, starty, endx, endy); |
833 |
|
if (ownbackstore) |
834 |
|
XDrawLine(display, backstore, gc, startx, starty, endx, endy); |
835 |
RESET_FUNCTION(opcode); |
RESET_FUNCTION(opcode); |
836 |
} |
} |
837 |
|
|
841 |
/* brush */ int colour) |
/* brush */ int colour) |
842 |
{ |
{ |
843 |
SET_FOREGROUND(colour); |
SET_FOREGROUND(colour); |
844 |
XFillRectangle(display, wnd, gc, x, y, cx, cy); |
FILL_RECTANGLE(x, y, cx, cy); |
845 |
} |
} |
846 |
|
|
847 |
void |
void |
858 |
XSetStipple(display, gc, (Pixmap)glyph); |
XSetStipple(display, gc, (Pixmap)glyph); |
859 |
XSetTSOrigin(display, gc, x, y); |
XSetTSOrigin(display, gc, x, y); |
860 |
|
|
861 |
XFillRectangle(display, wnd, gc, x, y, cx, cy); |
FILL_RECTANGLE(x, y, cx, cy); |
862 |
|
|
863 |
XSetFillStyle(display, gc, FillSolid); |
XSetFillStyle(display, gc, FillSolid); |
864 |
} |
} |
870 |
int bgcolour, int fgcolour, uint8 *text, uint8 length) |
int bgcolour, int fgcolour, uint8 *text, uint8 length) |
871 |
{ |
{ |
872 |
FONTGLYPH *glyph; |
FONTGLYPH *glyph; |
873 |
int i, offset; |
short offset; |
874 |
|
int i; |
875 |
|
|
876 |
SET_FOREGROUND(bgcolour); |
SET_FOREGROUND(bgcolour); |
877 |
|
|
878 |
if (boxcx > 1) |
if (boxcx > 1) |
879 |
XFillRectangle(display, wnd, gc, boxx, boxy, boxcx, boxcy); |
{ |
880 |
|
FILL_RECTANGLE(boxx, boxy, boxcx, boxcy); |
881 |
|
} |
882 |
else if (mixmode == MIX_OPAQUE) |
else if (mixmode == MIX_OPAQUE) |
883 |
XFillRectangle(display, wnd, gc, clipx, clipy, clipcx, clipcy); |
{ |
884 |
|
FILL_RECTANGLE(clipx, clipy, clipcx, clipcy); |
885 |
|
} |
886 |
|
|
887 |
/* Paint text, character by character */ |
/* Paint text, character by character */ |
888 |
for (i = 0; i < length; i++) |
for (i = 0; i < length; i++) |
893 |
{ |
{ |
894 |
offset = text[++i]; |
offset = text[++i]; |
895 |
if (offset & 0x80) |
if (offset & 0x80) |
896 |
offset = ((offset & 0x7f) << 8) | text[++i]; |
{ |
897 |
|
if (offset == 0x80) |
898 |
|
{ |
899 |
|
/* next two bytes, little-endian */ |
900 |
|
offset = text[++i]; |
901 |
|
offset |= text[++i] << 8; |
902 |
|
} |
903 |
|
else |
904 |
|
{ |
905 |
|
offset = (offset & 0x7f) << 8; |
906 |
|
offset |= text[++i]; |
907 |
|
} |
908 |
|
} |
909 |
|
|
910 |
if (flags & TEXT2_VERTICAL) |
if (flags & TEXT2_VERTICAL) |
911 |
y += offset; |
y += offset; |
933 |
Pixmap pix; |
Pixmap pix; |
934 |
XImage *image; |
XImage *image; |
935 |
|
|
936 |
pix = XCreatePixmap(display, wnd, cx, cy, depth); |
if (ownbackstore) |
937 |
XCopyArea(display, wnd, pix, gc, x, y, cx, cy, 0, 0); |
{ |
938 |
|
image = XGetImage(display, backstore, x, y, cx, cy, AllPlanes, |
939 |
image = XGetImage(display, pix, 0, 0, cx, cy, AllPlanes, ZPixmap); |
ZPixmap); |
940 |
|
} |
941 |
|
else |
942 |
|
{ |
943 |
|
pix = XCreatePixmap(display, wnd, cx, cy, depth); |
944 |
|
XCopyArea(display, wnd, pix, gc, x, y, cx, cy, 0, 0); |
945 |
|
image = XGetImage(display, pix, 0, 0, cx, cy, AllPlanes, |
946 |
|
ZPixmap); |
947 |
|
XFreePixmap(display, pix); |
948 |
|
} |
949 |
|
|
950 |
offset *= bpp/8; |
offset *= bpp/8; |
951 |
cache_put_desktop(offset, cx, cy, image->bytes_per_line, |
cache_put_desktop(offset, cx, cy, image->bytes_per_line, |
952 |
bpp/8, image->data); |
bpp/8, (uint8 *)image->data); |
953 |
|
|
954 |
XDestroyImage(image); |
XDestroyImage(image); |
|
XFreePixmap(display, pix); |
|
955 |
} |
} |
956 |
|
|
957 |
void |
void |
969 |
0, data, cx, cy, BitmapPad(display), |
0, data, cx, cy, BitmapPad(display), |
970 |
cx * bpp/8); |
cx * bpp/8); |
971 |
|
|
972 |
XPutImage(display, wnd, gc, image, 0, 0, x, y, cx, cy); |
if (ownbackstore) |
973 |
|
{ |
974 |
|
XPutImage(display, backstore, gc, image, 0, 0, x, y, cx, cy); |
975 |
|
XCopyArea(display, backstore, wnd, gc, x, y, cx, cy, x, y); |
976 |
|
} |
977 |
|
else |
978 |
|
{ |
979 |
|
XPutImage(display, wnd, gc, image, 0, 0, x, y, cx, cy); |
980 |
|
} |
981 |
|
|
982 |
XFree(image); |
XFree(image); |
983 |
} |
} |
|
|
|