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 |
74 |
|
#endif |
75 |
|
|
76 |
|
|
77 |
– |
// Do we replace PutScrap()? |
78 |
– |
#define REPLACE_PUTSCRAP 1 |
79 |
– |
|
80 |
– |
// Do we replace GetScrap()? |
81 |
– |
#define REPLACE_GETSCRAP 1 |
82 |
– |
|
77 |
|
// Do we want GetScrap() to check for TIMESTAMP and optimize out clipboard syncs? |
78 |
|
#define GETSCRAP_REQUESTS_TIMESTAMP 0 |
79 |
|
|
142 |
|
// Define a byte array (rewrite if it's a bottleneck) |
143 |
|
struct ByteArray : public vector<uint8> { |
144 |
|
void resize(int size) { reserve(size); vector<uint8>::resize(size); } |
145 |
< |
uint8 *data() { return &at(0); } |
145 |
> |
uint8 *data() { return &(*this)[0]; } |
146 |
|
}; |
147 |
|
|
148 |
|
// Clipboard data for requestors |
307 |
|
void PutScrap(uint32 type, void *scrap, int32 length) |
308 |
|
{ |
309 |
|
D(bug("PutScrap type %08lx, data %p, length %ld\n", type, scrap, length)); |
316 |
– |
if (!REPLACE_PUTSCRAP) |
317 |
– |
return; |
310 |
|
if (we_put_this_data) { |
311 |
|
we_put_this_data = false; |
312 |
|
return; |
381 |
|
void GetScrap(void **handle, uint32 type, int32 offset) |
382 |
|
{ |
383 |
|
D(bug("GetScrap handle %p, type %08x, offset %d\n", handle, type, offset)); |
392 |
– |
if (!REPLACE_GETSCRAP) |
393 |
– |
return; |
384 |
|
|
385 |
|
XDisplayLock(); |
386 |
|
do_getscrap(handle, type, offset); |
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); |
556 |
|
// Change requestor property |
557 |
|
XChangeProperty(x_display, req->requestor, req->property, |
558 |
|
xa_targets, 32, |
559 |
< |
PropModeReplace, (uint8 *)&targets.at(0), targets.size()); |
559 |
> |
PropModeReplace, (uint8 *)&targets[0], targets.size()); |
560 |
|
|
561 |
|
return true; |
562 |
|
} |