astrand / xclip

Command line interface to the X11 clipboard
GNU General Public License v2.0
1.04k stars 75 forks source link

Fixed loops incrementation to keep the right count #72

Closed kennbr34 closed 4 years ago

kennbr34 commented 4 years ago

I realized after reading this issue https://github.com/astrand/xclip/issues/8 that using '-loops 1' wasn't actually guaranteed to paste a selection into a web browser. For example, on a terminal window, one paste was fine, but to paste into a Chrome window, it needed to be set to 2 to get one pasting, whereas in the terminal it would still paste 2, so the way the loop was being incremented wasn't right. Using a Chromium window in MATE actually took 3 loops for one paste.

After playing with the code a little bit, I noticed that even for selections that needed the 32-bit mode of XChangeProperty that uses targets, that there would be a final call to the XChangeProperty that uses the 8-bit mode, so I changed the code to pass a pointer to dloop to xcin() and increment it only after those XChangeProperty calls. Now if '-loops 1' is specified it will only paste the selection once for the terminal or a browser window regardless of how many XChangeProperty calls it actually calls.

kennbr34 commented 4 years ago

My "fix" doesn't work correctly either, so closing this.