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.3 by gbeauche, 2003-12-31T18:16:55Z vs.
Revision 1.6 by gbeauche, 2004-01-01T11:29:38Z

# 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
78 // Do we want PutScrap() to ignore requests from klipper?
79 #define PUTSCRAP_IGNORES_KLIPPER 0
80
77   // Do we want GetScrap() to check for TIMESTAMP and optimize out clipboard syncs?
78   #define GETSCRAP_REQUESTS_TIMESTAMP 0
79  
# Line 270 | Line 266 | static bool wait_for_selection_notify_ev
266  
267  
268   /*
273 *  Check for a "klipper" window which, in older versions (3.1), was
274 *  polling and retrieving clipboard data several times per second.
275 */
276
277 static bool is_klipper_window_probe(Window w);
278 static bool is_klipper_window_check(Window w);
279 static bool (*is_klipper_window)(Window w) = is_klipper_window_probe;
280 static Window klipper_win = None;
281
282 static bool is_klipper_window_probe(Window w)
283 {
284        // We expect "klipper" to be within the first clients to request
285        // data from our clipboard
286        static int clients_countdown = 2;
287
288        bool found = false;
289        char *window_name;
290        if (XFetchName(x_display, w, &window_name) && !strcmp(window_name, "klipper")) {
291                D(bug(" found and ignore clipboard requests from klipper window id: 0x%08x\n", w));
292                klipper_win = w;
293                found = true;
294        }
295
296        if (found || --clients_countdown <= 0)
297                is_klipper_window = is_klipper_window_check;
298 }
299
300 static bool is_klipper_window_check(Window w)
301 {
302        return w == klipper_win;
303 }
304
305
306 /*
269   *  Initialization
270   */
271  
# Line 345 | 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));
348        if (!REPLACE_PUTSCRAP)
349                return;
310          if (we_put_this_data) {
311                  we_put_this_data = false;
312                  return;
# Line 363 | 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 383 | 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 399 | 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));
402        if (!REPLACE_GETSCRAP)
403                return;
384  
385          XDisplayLock();
386          do_getscrap(handle, type, offset);
# Line 450 | 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 677 | Line 658 | void ClipboardSelectionRequest(XSelectio
658          if (req->requestor == clip_win || req->selection != xa_clipboard)
659                  return;
660  
680 #if PUTSCRAP_IGNORES_KLIPPER
681        if (is_klipper_window(req->requestor))
682                return;
683 #endif
684
661          D(bug("Selection requested from 0x%lx to 0x%lx (%s) 0x%lx (%s)\n",
662                    req->requestor,
663                    req->selection,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines