45 |
|
* For safety purposes, we lock the X11 display in the emulator |
46 |
|
* thread during the whole GetScrap/PutScrap execution. Of course, we |
47 |
|
* temporarily release the lock when waiting for SelectioNotify. |
48 |
+ |
* |
49 |
+ |
* TODO: |
50 |
+ |
* - handle 'PICT' to image/png, image/ppm, PIXMAP (prefs order) |
51 |
+ |
* - handle 'styl' to text/richtext (OOo Writer) |
52 |
+ |
* - patch ZeroScrap so that we know when cached 'styl' is stale? |
53 |
|
*/ |
54 |
|
|
55 |
|
#include "sysdeps.h" |
331 |
|
{ |
332 |
|
clip_data.type = None; |
333 |
|
switch (type) { |
334 |
< |
case FOURCC('T','E','X','T'): |
334 |
> |
case FOURCC('T','E','X','T'): { |
335 |
|
D(bug(" clipping TEXT\n")); |
336 |
|
clip_data.type = XA_STRING; |
337 |
|
clip_data.data.clear(); |
351 |
|
break; |
352 |
|
} |
353 |
|
|
354 |
+ |
case FOURCC('s','t','y','l'): { |
355 |
+ |
D(bug(" clipping styl\n")); |
356 |
+ |
uint16 *p = (uint16 *)scrap; |
357 |
+ |
uint16 n = ntohs(*p++); |
358 |
+ |
D(bug(" %d styles (%d bytes)\n", n, length)); |
359 |
+ |
for (int i = 0; i < n; i++) { |
360 |
+ |
uint32 offset = ntohl(*(uint32 *)p); p += 2; |
361 |
+ |
uint16 line_height = ntohs(*p++); |
362 |
+ |
uint16 font_ascent = ntohs(*p++); |
363 |
+ |
uint16 font_family = ntohs(*p++); |
364 |
+ |
uint16 style_code = ntohs(*p++); |
365 |
+ |
uint16 char_size = ntohs(*p++); |
366 |
+ |
uint16 r = ntohs(*p++); |
367 |
+ |
uint16 g = ntohs(*p++); |
368 |
+ |
uint16 b = ntohs(*p++); |
369 |
+ |
D(bug(" offset=%d, height=%d, font ascent=%d, id=%d, style=%x, size=%d, RGB=%x/%x/%x\n", |
370 |
+ |
offset, line_height, font_ascent, font_family, style_code, char_size, r, g, b)); |
371 |
+ |
} |
372 |
+ |
break; |
373 |
+ |
} |
374 |
+ |
} |
375 |
+ |
|
376 |
|
// Acquire selection ownership |
377 |
|
if (clip_data.type != None) { |
378 |
|
clip_data.time = CurrentTime; |
440 |
|
long *atoms = (long *)data.data(); |
441 |
|
for (int i = 0; i < n_atoms; i++) { |
442 |
|
Atom target = atoms[i]; |
443 |
+ |
D(bug(" target %08x (%s)\n", target, XGetAtomName(x_display, target))); |
444 |
|
switch (type) { |
445 |
|
case FOURCC('T','E','X','T'): |
446 |
|
D(bug(" clipping TEXT\n")); |