allow fallback to x11
This commit is contained in:
parent
bebdea4e8e
commit
4fc1aa09a9
1 changed files with 23 additions and 4 deletions
|
|
@ -556,6 +556,7 @@ applegetsnarf(void)
|
||||||
PasteboardSyncFlags flags;
|
PasteboardSyncFlags flags;
|
||||||
UInt32 i;
|
UInt32 i;
|
||||||
|
|
||||||
|
// fprint(2, "applegetsnarf\n");
|
||||||
qlock(&clip.lk);
|
qlock(&clip.lk);
|
||||||
if(clip.apple == nil){
|
if(clip.apple == nil){
|
||||||
if(PasteboardCreate(kPasteboardClipboard, &clip.apple) != noErr){
|
if(PasteboardCreate(kPasteboardClipboard, &clip.apple) != noErr){
|
||||||
|
|
@ -566,8 +567,9 @@ applegetsnarf(void)
|
||||||
}
|
}
|
||||||
flags = PasteboardSynchronize(clip.apple);
|
flags = PasteboardSynchronize(clip.apple);
|
||||||
if(flags&kPasteboardClientIsOwner){
|
if(flags&kPasteboardClientIsOwner){
|
||||||
|
s = strdup(clip.buf);
|
||||||
qunlock(&clip.lk);
|
qunlock(&clip.lk);
|
||||||
return strdup(clip.buf);
|
return s;
|
||||||
}
|
}
|
||||||
if(PasteboardGetItemCount(clip.apple, &nitem) != noErr){
|
if(PasteboardGetItemCount(clip.apple, &nitem) != noErr){
|
||||||
fprint(2, "apple pasteboard get item count failed\n");
|
fprint(2, "apple pasteboard get item count failed\n");
|
||||||
|
|
@ -608,6 +610,8 @@ appleputsnarf(char *s)
|
||||||
CFDataRef cfdata;
|
CFDataRef cfdata;
|
||||||
PasteboardSyncFlags flags;
|
PasteboardSyncFlags flags;
|
||||||
|
|
||||||
|
// fprint(2, "appleputsnarf\n");
|
||||||
|
|
||||||
if(strlen(s) >= SnarfSize)
|
if(strlen(s) >= SnarfSize)
|
||||||
return;
|
return;
|
||||||
qlock(&clip.lk);
|
qlock(&clip.lk);
|
||||||
|
|
@ -648,13 +652,26 @@ appleputsnarf(char *s)
|
||||||
/* CFRelease(cfdata); ??? */
|
/* CFRelease(cfdata); ??? */
|
||||||
qunlock(&clip.lk);
|
qunlock(&clip.lk);
|
||||||
}
|
}
|
||||||
|
static int useapplesnarf = -1;
|
||||||
|
static int
|
||||||
|
checkapplesnarf(void)
|
||||||
|
{
|
||||||
|
char *x;
|
||||||
|
|
||||||
|
x = getenv("USEX11SNARF");
|
||||||
|
if(x && x[0])
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
#endif /* APPLESNARF */
|
#endif /* APPLESNARF */
|
||||||
|
|
||||||
void
|
void
|
||||||
putsnarf(char *data)
|
putsnarf(char *data)
|
||||||
{
|
{
|
||||||
#ifdef APPLESNARF
|
#ifdef APPLESNARF
|
||||||
if(1){
|
if(useapplesnarf == -1)
|
||||||
|
useapplesnarf = checkapplesnarf();
|
||||||
|
if(useapplesnarf){
|
||||||
appleputsnarf(data);
|
appleputsnarf(data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -666,7 +683,9 @@ char*
|
||||||
getsnarf(void)
|
getsnarf(void)
|
||||||
{
|
{
|
||||||
#ifdef APPLESNARF
|
#ifdef APPLESNARF
|
||||||
if(1)
|
if(useapplesnarf == -1)
|
||||||
|
useapplesnarf = checkapplesnarf();
|
||||||
|
if(useapplesnarf)
|
||||||
return applegetsnarf();
|
return applegetsnarf();
|
||||||
#endif
|
#endif
|
||||||
return _xgetsnarf(_x.snarfcon);
|
return _xgetsnarf(_x.snarfcon);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue