ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/clip_unix.cpp
(Generate patch)

Comparing SheepShaver/src/Unix/clip_unix.cpp (file contents):
Revision 1.4 by gbeauche, 2003-12-31T18:23:41Z vs.
Revision 1.8 by cebix, 2004-01-12T15:37:21Z

# Line 1 | Line 1
1   /*
2   *  clip_unix.cpp - Clipboard handling, Unix implementation
3   *
4 < *  SheepShaver (C) 1997-2003 Christian Bauer and Marc Hellwig
4 > *  SheepShaver (C) 1997-2004 Christian Bauer and Marc Hellwig
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 45 | Line 45
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"
# Line 69 | Line 74 | using std::vector;
74   #endif
75  
76  
72 // Do we replace PutScrap()?
73 #define REPLACE_PUTSCRAP 1
74
75 // Do we replace GetScrap()?
76 #define REPLACE_GETSCRAP 1
77
77   // Do we want GetScrap() to check for TIMESTAMP and optimize out clipboard syncs?
78   #define GETSCRAP_REQUESTS_TIMESTAMP 0
79  
# Line 308 | Line 307 | void ClipExit(void)
307   void PutScrap(uint32 type, void *scrap, int32 length)
308   {
309          D(bug("PutScrap type %08lx, data %p, length %ld\n", type, scrap, length));
311        if (!REPLACE_PUTSCRAP)
312                return;
310          if (we_put_this_data) {
311                  we_put_this_data = false;
312                  return;
# Line 326 | Line 323 | static void do_putscrap(uint32 type, voi
323   {
324          clip_data.type = None;
325          switch (type) {
326 <        case FOURCC('T','E','X','T'):
326 >        case FOURCC('T','E','X','T'): {
327                  D(bug(" clipping TEXT\n"));
328                  clip_data.type = XA_STRING;
329                  clip_data.data.clear();
# Line 346 | Line 343 | static void do_putscrap(uint32 type, voi
343                  break;
344          }
345  
346 +        case FOURCC('s','t','y','l'): {
347 +                D(bug(" clipping styl\n"));
348 +                uint16 *p = (uint16 *)scrap;
349 +                uint16 n = ntohs(*p++);
350 +                D(bug(" %d styles (%d bytes)\n", n, length));
351 +                for (int i = 0; i < n; i++) {
352 +                        uint32 offset = ntohl(*(uint32 *)p); p += 2;
353 +                        uint16 line_height = ntohs(*p++);
354 +                        uint16 font_ascent = ntohs(*p++);
355 +                        uint16 font_family = ntohs(*p++);
356 +                        uint16 style_code = ntohs(*p++);
357 +                        uint16 char_size = ntohs(*p++);
358 +                        uint16 r = ntohs(*p++);
359 +                        uint16 g = ntohs(*p++);
360 +                        uint16 b = ntohs(*p++);
361 +                        D(bug("  offset=%d, height=%d, font ascent=%d, id=%d, style=%x, size=%d, RGB=%x/%x/%x\n",
362 +                                  offset, line_height, font_ascent, font_family, style_code, char_size, r, g, b));
363 +                }
364 +                break;
365 +        }
366 +        }
367 +
368          // Acquire selection ownership
369          if (clip_data.type != None) {
370                  clip_data.time = CurrentTime;
# Line 362 | Line 381 | static void do_putscrap(uint32 type, voi
381   void GetScrap(void **handle, uint32 type, int32 offset)
382   {
383          D(bug("GetScrap handle %p, type %08x, offset %d\n", handle, type, offset));
365        if (!REPLACE_GETSCRAP)
366                return;
384  
385          XDisplayLock();
386          do_getscrap(handle, type, offset);
# Line 413 | Line 430 | static void do_getscrap(void **handle, u
430          long *atoms = (long *)data.data();
431          for (int i = 0; i < n_atoms; i++) {
432                  Atom target = atoms[i];
433 +                D(bug("  target %08x (%s)\n", target, XGetAtomName(x_display, target)));
434                  switch (type) {
435                  case FOURCC('T','E','X','T'):
436                          D(bug(" clipping TEXT\n"));
# Line 469 | Line 487 | static void do_getscrap(void **handle, u
487                  }
488  
489                  // Add new data to clipboard
490 <                static uint8 proc[] = {
491 <                        0x59, 0x8f,                                     // subq.l       #4,sp
492 <                        0xa9, 0xfc,                                     // ZeroScrap()
493 <                        0x2f, 0x3c, 0, 0, 0, 0,         // move.l       #length,-(sp)
494 <                        0x2f, 0x3c, 0, 0, 0, 0,         // move.l       #type,-(sp)
495 <                        0x2f, 0x3c, 0, 0, 0, 0,         // move.l       #outbuf,-(sp)
496 <                        0xa9, 0xfe,                                     // PutScrap()
497 <                        0x58, 0x8f,                                     // addq.l       #4,sp
498 <                        M68K_RTS >> 8, M68K_RTS
490 >                static uint16 proc[] = {
491 >                        PW(0x598f),                                     // subq.l       #4,sp
492 >                        PW(0xa9fc),                                     // ZeroScrap()
493 >                        PW(0x2f3c), 0, 0,                       // move.l       #length,-(sp)
494 >                        PW(0x2f3c), 0, 0,                       // move.l       #type,-(sp)
495 >                        PW(0x2f3c), 0, 0,                       // move.l       #outbuf,-(sp)
496 >                        PW(0xa9fe),                                     // PutScrap()
497 >                        PW(0x588f),                                     // addq.l       #4,sp
498 >                        PW(M68K_RTS)
499                  };
500 <                uint32 proc_area = (uint32)proc; // FIXME: make sure 32-bit relocs are used
500 >                uint32 proc_area = (uint32)proc;
501                  WriteMacInt32(proc_area +  6, data.size());
502                  WriteMacInt32(proc_area + 12, type);
503                  WriteMacInt32(proc_area + 18, scrap_area);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines