Skip to content
  • Jon Turney's avatar
    hw/xwin: Retrieve TARGETS to avoid unnecessary failing conversion attempts · 851b5041
    Jon Turney authored
    See http://cygwin.com/ml/cygwin-xfree/2013-07/msg00016.html
    
    It looks like the change in a9aca218
    
     had some
    unforseen consequences.
    
    If the X11 selection contents are not convertable to COMPOUND_TEXT, UTF8_STRING
    or STRING format (for example, if it is an image), after those conversion
    attempts have failed, we sit in winProcessXEventsTimeout() until the timeout
    expires.
    
    It also seems that maybe gnuplot doesn't respond correctly to this sequence of
    conversion requests and doesn't reply to some of them, which also causes us to
    sit in winProcessXEventsTimeout() until the timeout expires.
    
    The Windows application which has requested the clipboard contents via
    GetClipboardContents() is blocked until we return from WM_RENDERFORMAT, so
    sitting waiting for this timeout to expire should be avoided.
    
    So instead, explicitly request conversion to the TARGETS target, choose
    the most preferred format, and request conversion to that.
    
    Also: if there is no owned selection, there is nothing to paste, so don't bother
    trying to convert it.
    
    v2: Fix compilation with -Werror=declaration-after-statement
    
    Signed-off-by: default avatarJon TURNEY <jon.turney@dronecode.org.uk>
    Reviewed-by: default avatarColin Harrison <colin.harrison@virgin.net>
    851b5041