tallow fallback to x11 - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 4fc1aa09a95ca3fc4716a98a264a3f58b95b0d2a
 (DIR) parent bebdea4e8e1a93c14099a7b8182ddfcb6d2cae14
 (HTM) Author: rsc <devnull@localhost>
       Date:   Tue, 28 Feb 2006 13:13:39 +0000
       
       allow fallback to x11
       
       Diffstat:
         M src/libdraw/x11-itrans.c            |      27 +++++++++++++++++++++++----
       
       1 file changed, 23 insertions(+), 4 deletions(-)
       ---
 (DIR) diff --git a/src/libdraw/x11-itrans.c b/src/libdraw/x11-itrans.c
       t@@ -555,7 +555,8 @@ applegetsnarf(void)
                PasteboardItemID id;
                PasteboardSyncFlags flags;
                UInt32 i;
       -        
       +
       +//        fprint(2, "applegetsnarf\n");
                qlock(&clip.lk);
                if(clip.apple == nil){
                        if(PasteboardCreate(kPasteboardClipboard, &clip.apple) != noErr){
       t@@ -566,8 +567,9 @@ applegetsnarf(void)
                }
                flags = PasteboardSynchronize(clip.apple);
                if(flags&kPasteboardClientIsOwner){
       +                s = strdup(clip.buf);
                        qunlock(&clip.lk);
       -                return strdup(clip.buf);
       +                return s;
                }
                if(PasteboardGetItemCount(clip.apple, &nitem) != noErr){
                        fprint(2, "apple pasteboard get item count failed\n");
       t@@ -608,6 +610,8 @@ appleputsnarf(char *s)
                CFDataRef cfdata;
                PasteboardSyncFlags flags;
        
       +//        fprint(2, "appleputsnarf\n");
       +
                if(strlen(s) >= SnarfSize)
                        return;
                qlock(&clip.lk);
       t@@ -648,13 +652,26 @@ appleputsnarf(char *s)
                /* CFRelease(cfdata); ??? */
                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 */
        
        void
        putsnarf(char *data)
        {
        #ifdef APPLESNARF
       -        if(1){
       +        if(useapplesnarf == -1)
       +                useapplesnarf = checkapplesnarf();
       +        if(useapplesnarf){
                        appleputsnarf(data);
                        return;
                }
       t@@ -666,7 +683,9 @@ char*
        getsnarf(void)
        {
        #ifdef APPLESNARF
       -        if(1)
       +        if(useapplesnarf == -1)
       +                useapplesnarf = checkapplesnarf();
       +        if(useapplesnarf)
                        return applegetsnarf();
        #endif
                return _xgetsnarf(_x.snarfcon);