1

I'm trying to create a property so i can get clipboard data from other programs with XConvertSelection(), the code is:

int main() {
    Display *dpy;
    Window owner, target_window, root;
    int screen;
    Atom selection, target_property, type;
    XEvent ev;
    XSelectionEvent *sev;

    dpy = XOpenDisplay(NULL);
    if (!dpy)
    {
        fprintf(stderr, "Could not open X display\n");
        return 1;
    }

    screen = DefaultScreen(dpy);
    root = RootWindow(dpy, screen);

    selections = XInternAtom(dpy, "CLIPBOARD", False);
    type = XInternAtom(dpy, "UTF8_STRING", False);

    owner = XGetSelectionOwner(dpy, selection);
    if (owner == None)
    {
        printf("'CLIPBOARD' has no owner\n");
        return 1;
    }
    printf("0x%lX\n", owner);

    /* The selection owner will store the data in a property on this
     * window: */
    target_window = XCreateSimpleWindow(dpy, root, -10, -10, 1, 1, 0, 0, 0);
    printf("Our window: %lX\n", target_window);
    /* That's the property used by the selection owner */
    target_property = XInternAtom(dpy, "PUT_DATA_HERE", False);

    /* Request conversion to UTF-8. */
    XConvertSelection(dpy, selection, type, target_property, target_window,
                      CurrentTime);
    [...]

this is the code relevant for my issue, from the code here, i suppose that i created a property called PUT_DATA_HERE, but when i run xprop against the target_window i created, i dont find any of the properties i created, but when i run xlsatoms i find PUT_DATA_HERE in the output as an Atom.
XConvertSelection() is supposed to tell the owner of the Selection to put the data into the target_property but i only created Atom.
am i creating here a property or an Atom, i don't think i understand what a property is, can someone please explain it to me .

hakim
  • 33
  • 4

0 Answers0