strange copy paste problem - Xwindows

This is a discussion on strange copy paste problem - Xwindows ; Hello all, It is very strange and I was struggling on it for 2 days. I wrote a agent based on qt (QClipboard) to monitor some other application's text, ie GVIM. I used XTest library to simulate input and mouse ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: strange copy paste problem

  1. strange copy paste problem

    Hello all,

    It is very strange and I was struggling on it for 2 days.
    I wrote a agent based on qt (QClipboard) to monitor some other application's
    text, ie GVIM.

    I used XTest library to simulate input and mouse event to GVIM, let GVIM to
    copy its text to clipboard ("+y). Then in the agent, I use
    QApplication::clipboard()->text() to get the clipboard text.
    The strange thing is I can only get the text at first time. After the second
    operation("+y), the GVIM doesn't copy its text to clipboard.

    Also, when I used qt clipboard to set the clipboard content, I got
    QClipboard::setData: Cannot set X11 selection owner for CLIPBOARD error
    messange. I saw the source code or qclipboard. It is because
    XSetSelectionOwner cannot set the owner to clipboard. What's the problem
    with the XSetSelectionOwner?

    If I just do this operation by myslef, not automatically by agent, there's
    no any problem.

    Did I miss something? I appreciate your help.

    Thanks,
    -Max



  2. Re: strange copy paste problem

    Hello all,

    I figured out this problem. It is because the selection system of xwindow
    need client to catch event to set or clear the owner of the selection.

    I add qApp->processEvents() before I use clipboard object. Everything works
    as expected.

    Just write this to give some hints to someone if he/she met same problem as
    I .

    Cheers,
    -Max

    "Max" wrote in message
    news:S%iRa.13722$kI5.509@nwrddc02.gnilink.net...
    > Hello all,
    >
    > It is very strange and I was struggling on it for 2 days.
    > I wrote a agent based on qt (QClipboard) to monitor some other

    application's
    > text, ie GVIM.
    >
    > I used XTest library to simulate input and mouse event to GVIM, let GVIM

    to
    > copy its text to clipboard ("+y). Then in the agent, I use
    > QApplication::clipboard()->text() to get the clipboard text.
    > The strange thing is I can only get the text at first time. After the

    second
    > operation("+y), the GVIM doesn't copy its text to clipboard.
    >
    > Also, when I used qt clipboard to set the clipboard content, I got
    > QClipboard::setData: Cannot set X11 selection owner for CLIPBOARD error
    > messange. I saw the source code or qclipboard. It is because
    > XSetSelectionOwner cannot set the owner to clipboard. What's the problem
    > with the XSetSelectionOwner?
    >
    > If I just do this operation by myslef, not automatically by agent, there's
    > no any problem.
    >
    > Did I miss something? I appreciate your help.
    >
    > Thanks,
    > -Max
    >
    >




+ Reply to Thread