Skip to main content
added 38 characters in body
Source Link
user313992
user313992
  XSetSelectionOwner(display, XA_PRIMARY, None, CurrentTime);

This will not work. As the first line in the DESCRIPTION of XSetSelectionOwner(3) says:

The XSetSelectionOwner function changes the owner and last-change time for the specified selection and has no effect if the specified time is earlier than the current last-change time of the specified selection or is later than the current X server time.

You'll have to pass it a real timestamp, which you could obtain from an XEvent received from the server. This is what I did in my own implementation of xsel:

Time getctime(void){
        XSelectInput(dpy, w, PropertyChangeMask);
        XStoreName(dpy, w, "xsel");
        for(;;){
                XEvent e;
                XNextEvent(dpy, &e);
                if(e.type == PropertyNotify && e.xproperty.window == w)
                        return e.xproperty.time;
        }
}

I set a property on a window, then wait for the PropertyNotify event and then get the timestamp from the XPropertyEvent structure. The window can be an InputOnly one. This is also described in the xlib programming manual, or some X11 manpage.

Unfortunately, that will also mean that your little program won't be quick enough either, as it has to wait for that event ;-)

I don't think that the answers to the linked question are satisfactory. You better explore using some LD_PRELOAD hack, or modifying the programs that are causing you trouble.

  XSetSelectionOwner(display, XA_PRIMARY, None, CurrentTime);

This will not work. As the first line in the DESCRIPTION of XSetSelectionOwner(3) says:

The XSetSelectionOwner function changes the owner and last-change time for the specified selection and has no effect if the specified time is earlier than the current last-change time of the specified selection or is later than the current X server time.

You'll have to pass it a real timestamp, which you could obtain from an XEvent received from the server. This is what I did in my own implementation of xsel:

Time getctime(void){
        XSelectInput(dpy, w, PropertyChangeMask);
        XStoreName(dpy, w, "xsel");
        for(;;){
                XEvent e;
                XNextEvent(dpy, &e);
                if(e.type == PropertyNotify && e.xproperty.window == w)
                        return e.xproperty.time;
        }
}

I set a property on a window, then wait for the PropertyNotify event and then get the timestamp from the XPropertyEvent structure. This is also described in the xlib programming manual, or some X11 manpage.

Unfortunately, that will also mean that your little program won't be quick enough either, as it has to wait for that event ;-)

I don't think that the answers to the linked question are satisfactory. You better explore using some LD_PRELOAD hack, or modifying the programs that are causing you trouble.

  XSetSelectionOwner(display, XA_PRIMARY, None, CurrentTime);

This will not work. As the first line in the DESCRIPTION of XSetSelectionOwner(3) says:

The XSetSelectionOwner function changes the owner and last-change time for the specified selection and has no effect if the specified time is earlier than the current last-change time of the specified selection or is later than the current X server time.

You'll have to pass it a real timestamp, which you could obtain from an XEvent received from the server. This is what I did in my own implementation of xsel:

Time getctime(void){
        XSelectInput(dpy, w, PropertyChangeMask);
        XStoreName(dpy, w, "xsel");
        for(;;){
                XEvent e;
                XNextEvent(dpy, &e);
                if(e.type == PropertyNotify && e.xproperty.window == w)
                        return e.xproperty.time;
        }
}

I set a property on a window, wait for the PropertyNotify event and then get the timestamp from the XPropertyEvent structure. The window can be an InputOnly one. This is also described in the xlib programming manual, or some X11 manpage.

Unfortunately, that will also mean that your little program won't be quick enough either, as it has to wait for that event ;-)

I don't think that the answers to the linked question are satisfactory. You better explore using some LD_PRELOAD hack, or modifying the programs that are causing you trouble.

added 449 characters in body
Source Link
user313992
user313992
  XSetSelectionOwner(display, XA_PRIMARY, None, CurrentTime);

This will not work. As the first line in the DESCRIPTION of XSetSelectionOwner(3) says:

The XSetSelectionOwner function changes the owner and last-change time for the specified selection and has no effect if the specified time is earlier than the current last-change time of the specified selection time of the specified selection or is later than the current X server time.

You'll have to pass it a real timestamp, which you could obtain from an XEvent received from the server. This is what I did in my own implementation of xsel:

Time getctime(void){
        XSelectInput(dpy, w, PropertyChangeMask);
        XStoreName(dpy, w, "xsel");
        for(;;){
                XEvent e;
                XNextEvent(dpy, &e);
                if(e.type == PropertyNotify && e.xproperty.window == w)
                        return e.xproperty.time;
        }
}

I set a property on a window, then wait for the PropertyNotify event and then get itthe timestamp from the XPropertyEvent structure. This is also described in the xlib programming manual, or some X11 manpage.

Unfortunately, that will also mean that your little program won't be quick enough either, as it has to wait for that event ;-)

I don't think that the answers to the linked question are satisfactory. You better explore using some LD_PRELOAD hack, or modifying the programs that are causing you trouble.

  XSetSelectionOwner(display, XA_PRIMARY, None, CurrentTime);

This will not work. As the first line in the DESCRIPTION of XSetSelectionOwner(3) says:

The XSetSelectionOwner function changes the owner and last-change time for the specified selection and has no effect if the specified time is earlier than the current last-change time of the specified selection or is later than the current X server time.

You'll have to pass it a real timestamp, which you could obtain from an XEvent received from the server. This is what I did in my own implementation of xsel:

Time getctime(void){
        XSelectInput(dpy, w, PropertyChangeMask);
        XStoreName(dpy, w, "xsel");
        for(;;){
                XEvent e;
                XNextEvent(dpy, &e);
                if(e.type == PropertyNotify && e.xproperty.window == w)
                        return e.xproperty.time;
        }
}

I set a property on a window, then wait for the PropertyNotify event and then get it from the XPropertyEvent structure. This is also described in the xlib programming manual, or some X11 manpage.

  XSetSelectionOwner(display, XA_PRIMARY, None, CurrentTime);

This will not work. As the first line in the DESCRIPTION of XSetSelectionOwner(3) says:

The XSetSelectionOwner function changes the owner and last-change time for the specified selection and has no effect if the specified time is earlier than the current last-change time of the specified selection or is later than the current X server time.

You'll have to pass it a real timestamp, which you could obtain from an XEvent received from the server. This is what I did in my own implementation of xsel:

Time getctime(void){
        XSelectInput(dpy, w, PropertyChangeMask);
        XStoreName(dpy, w, "xsel");
        for(;;){
                XEvent e;
                XNextEvent(dpy, &e);
                if(e.type == PropertyNotify && e.xproperty.window == w)
                        return e.xproperty.time;
        }
}

I set a property on a window, then wait for the PropertyNotify event and then get the timestamp from the XPropertyEvent structure. This is also described in the xlib programming manual, or some X11 manpage.

Unfortunately, that will also mean that your little program won't be quick enough either, as it has to wait for that event ;-)

I don't think that the answers to the linked question are satisfactory. You better explore using some LD_PRELOAD hack, or modifying the programs that are causing you trouble.

Source Link
user313992
user313992

  XSetSelectionOwner(display, XA_PRIMARY, None, CurrentTime);

This will not work. As the first line in the DESCRIPTION of XSetSelectionOwner(3) says:

The XSetSelectionOwner function changes the owner and last-change time for the specified selection and has no effect if the specified time is earlier than the current last-change time of the specified selection or is later than the current X server time.

You'll have to pass it a real timestamp, which you could obtain from an XEvent received from the server. This is what I did in my own implementation of xsel:

Time getctime(void){
        XSelectInput(dpy, w, PropertyChangeMask);
        XStoreName(dpy, w, "xsel");
        for(;;){
                XEvent e;
                XNextEvent(dpy, &e);
                if(e.type == PropertyNotify && e.xproperty.window == w)
                        return e.xproperty.time;
        }
}

I set a property on a window, then wait for the PropertyNotify event and then get it from the XPropertyEvent structure. This is also described in the xlib programming manual, or some X11 manpage.