Skip to content

Commit

Permalink
X11: Fixed SelectionRequest replies for target TARGETS.
Browse files Browse the repository at this point in the history
Fixes Google Chrome, etc, freezing up when SDL owns the clipboard selection
and actually sends thems the correct text for pasting. Confirmed working with
Unicode strings in UTF-8 format.

There were a few tweaks in this patch, but the specific fix is that
event.xselection.target in the SelectionNotify event we send back in reply
must be set to the same atom as the request ("TARGETS" in this case), and
we failed to do that in this special case. Things that don't ask for a target,
like the Gnome Terminal app, worked fine because they don't ask for TARGETS
and just go right to asking for a UTF8_STRING, and Mozilla apparently just
was more liberal in what they accepted in reply.

Chrome would reject our wrong reply and freeze up waiting for a valid one.
Someone should fix that in Chrome, too.  :)

Fixes Bugzilla #2926.
  • Loading branch information
icculus committed Jun 4, 2015
1 parent 96aef8c commit 360d05b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/video/x11/SDL_x11events.c
Expand Up @@ -1189,6 +1189,7 @@ X11_DispatchEvent(_THIS)
sevent.xselection.property = None;
sevent.xselection.requestor = req->requestor;
sevent.xselection.time = req->time;

if (X11_XGetWindowProperty(display, DefaultRootWindow(display),
X11_GetSDLCutBufferClipboardType(display), 0, INT_MAX/4, False, req->target,
&sevent.xselection.target, &seln_format, &nbytes,
Expand All @@ -1200,12 +1201,13 @@ X11_DispatchEvent(_THIS)
seln_data, nbytes);
sevent.xselection.property = req->property;
} else if (XA_TARGETS == req->target) {
Atom SupportedFormats[] = { sevent.xselection.target, XA_TARGETS };
Atom SupportedFormats[] = { XA_TARGETS, sevent.xselection.target };
X11_XChangeProperty(display, req->requestor, req->property,
XA_ATOM, 32, PropModeReplace,
(unsigned char*)SupportedFormats,
sizeof(SupportedFormats)/sizeof(*SupportedFormats));
SDL_arraysize(SupportedFormats));
sevent.xselection.property = req->property;
sevent.xselection.target = XA_TARGETS;
}
X11_XFree(seln_data);
}
Expand Down

0 comments on commit 360d05b

Please sign in to comment.