Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions player/clipboard/clipboard-x11.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ static bool clipboard_x11_init(struct clipboard_x11_priv *x11, bool xwayland)
MP_FATAL(x11, "Xfixes init failed\n");
goto err;
}

// XFixesSelectionNotifyEvent does not give an initial notification
// so request selection here
XConvertSelection(x11->display, XA(x11, CLIPBOARD), XA(x11, UTF8_STRING),
XA(x11, MPV_CLIPBOARD), x11->window, CurrentTime);
XConvertSelection(x11->display, XA_PRIMARY, XA(x11, UTF8_STRING),
XA(x11, MPV_PRIMARY), x11->window, CurrentTime);
XFlush(x11->display);

return true;

err:
Expand Down Expand Up @@ -186,11 +195,12 @@ static bool clipboard_x11_dispatch_events(struct clipboard_x11_priv *x11, int64_
MP_TRACE(x11, "XEvent: %d\n", event.type);
if (event.type == x11->XFixesSelectionNotifyEvent) {
XFixesSelectionNotifyEvent *ev = (XFixesSelectionNotifyEvent *)&event;
if (ev->owner != x11->window &&
(ev->selection == XA(x11, CLIPBOARD) || ev->selection == XA_PRIMARY))
{
if (ev->owner != x11->window && ev->selection == XA(x11, CLIPBOARD)) {
XConvertSelection(x11->display, ev->selection, XA(x11, UTF8_STRING),
XA(x11, MPV_CLIPBOARD), x11->window, CurrentTime);
} else if (ev->owner != x11->window && ev->selection == XA_PRIMARY) {
XConvertSelection(x11->display, ev->selection, XA(x11, UTF8_STRING),
XA(x11, MPV_SELECTION), x11->window, CurrentTime);
XA(x11, MPV_PRIMARY), x11->window, CurrentTime);
}
} else if (event.type == SelectionRequest) {
clipboard_x11_handle_selection_request(x11, &event);
Expand Down