https://bz.apache.org/ooo/show_bug.cgi?id=128612

--- Comment #21 from [email protected] ---
(In reply to Arrigo Marchiori from comment #20)
> (In reply to damjan from comment #19)
> > (In reply to Arrigo Marchiori from comment #2)
> > > I see the same, intermittent issue with release 4.1.15 on Ubuntu Linux.
> > > 
> > > The same problems happen much less frequently on OpenSUSE Linux, still 
> > > with
> > > 4.1.5.
> > 
> > Hi Arrigo
> > 
> > Which desktop are you using on Ubuntu and OpenSUSE?
> > 
> > And are you running X11 or Wayland?
> 
> KDE Plasma, X11, on both.
> 
> KDE has its own clipboard manager and that may be getting into our way, as I
> suppose from reading your findings on XFCE.
> 
> If you could share your X clipboard monitoring tool, I could try to confirm
> the change of ownership?

Thank you. Yes it sounds like KDE's clipboard manager is doing something wrong
:-(.

This quickly hacked tool (and its SCons build file) will tell you who owns the
"CLIPBOARD" selection:

SConstruct:

---snip---
e = Environment()
e.ParseConfig('pkg-config --cflags --libs x11')
e.Program('x11_selection_owner', 'x11_selection_owner.c')
---snip---

x11_selection_owner.c:

---snip---
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>

#define MAX_PROPERTY_VALUE_LEN 4096

typedef unsigned long ulong;

static char *get_property(Display *, Window, Atom , const char *, ulong *);

int main(void) {
    // Open the Display
    Atom clipboard;
    Display *display = XOpenDisplay(NULL);

    // Get the selection window
    clipboard = XInternAtom(display, "CLIPBOARD", 0);
    Window selection_owner = XGetSelectionOwner(display, clipboard);

    if(!selection_owner) {
        exit(0);
    } else {
          char *window_name = get_property(display, selection_owner, XA_STRING,
"WM_NAME", NULL);
          printf("window id 0x%lx, name %s\n", selection_owner, window_name);
    }

    XCloseDisplay(display);
}

static char *get_property (Display *disp, Window win,
        Atom xa_prop_type, const char *prop_name, ulong *size) {
    Atom xa_prop_name;
    Atom xa_ret_type;
    int ret_format;
    ulong ret_nitems;
    ulong ret_bytes_after;
    ulong tmp_size;
    unsigned char *ret_prop;
    char *ret;

    xa_prop_name = XInternAtom(disp, prop_name, False);

    if (XGetWindowProperty(disp, win, xa_prop_name, 0,
            MAX_PROPERTY_VALUE_LEN / 4, False,
            xa_prop_type, &xa_ret_type, &ret_format,     
            &ret_nitems, &ret_bytes_after, &ret_prop) != Success) {
        printf("Cannot get %s property.\n", prop_name);
        return NULL;
    }

    if (xa_ret_type != xa_prop_type) {
        printf("Invalid type of %s property.\n", prop_name);
        XFree(ret_prop);
        return NULL;
    }

    /* null terminate the result to make string handling easier */
    tmp_size = (ret_format / 8) * ret_nitems;
    /* Correct 64 Architecture implementation of 32 bit data */
    if(ret_format==32) tmp_size *= sizeof(long)/4;
    ret = (char *)malloc(tmp_size + 1);
    memcpy(ret, ret_prop, tmp_size);
    ret[tmp_size] = '\0';

    if (size) {
        *size = tmp_size;
    }

    XFree(ret_prop);
    return ret;
}
---snip---

Running "./x11_clipboard_formats" after copying a cell should let you
distinguish whether AOO has it, or some clipboard manager.

You can also examine the current X11 clipboard formats with:

$ xclip -selection CLIPBOARD -target TARGETS

and replace "TARGETS" with one of the listed formats to paste to stdout in that
format.

-- 
You are receiving this mail because:
You are the assignee for the issue.

Reply via email to