forked from AuroraMiddleware/gtk
wayland: Add some dumb support for the TARGETS selection
The way that GtkTextView et al pop up their context menu is to first query to see if the clipboard has some text, and if so, enable the Paste menu item. But since the Wayland backend hasn't had the greatest selection and clipboard code, the callback for the clipboard got dropped on the floor. Add some simple code to respond to the TARGETS selection. This makes right-clicking on a GtkTextView work fine.
This commit is contained in:
parent
ece9ae4bc5
commit
f4b212abd4
@ -1770,6 +1770,15 @@ _gdk_wayland_device_get_button_press_serial (GdkWaylandDeviceData *device)
|
||||
return device->button_press_serial;
|
||||
}
|
||||
|
||||
static GdkAtom
|
||||
mime_type_to_gdk_atom (char *mime_type)
|
||||
{
|
||||
if (strcmp (mime_type, "text/plain;charset=utf8"))
|
||||
return gdk_atom_intern_static_string ("UTF8_STRING");
|
||||
|
||||
return GDK_NONE;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_wayland_device_get_selection_type_atoms (GdkDevice *gdk_device,
|
||||
GdkAtom **atoms_out)
|
||||
@ -1793,13 +1802,7 @@ gdk_wayland_device_get_selection_type_atoms (GdkDevice *gdk_device,
|
||||
|
||||
/* Convert list of targets to atoms */
|
||||
for (i = 0; i < device->selection_offer->types->len; i++)
|
||||
{
|
||||
atoms[i] = gdk_atom_intern (device->selection_offer->types->pdata[i],
|
||||
FALSE);
|
||||
GDK_NOTE (MISC,
|
||||
g_message (G_STRLOC ": Adding atom for %s",
|
||||
(char *)device->selection_offer->types->pdata[i]));
|
||||
}
|
||||
atoms[i] = mime_type_to_gdk_atom (device->selection_offer->types->pdata[i]);
|
||||
|
||||
*atoms_out = atoms;
|
||||
return device->selection_offer->types->len;
|
||||
|
@ -283,6 +283,24 @@ gtk_clipboard_wayland_request_contents (GtkClipboard *gtkclipboard,
|
||||
device_manager = gdk_display_get_device_manager (gdk_display_get_default ());
|
||||
device = gdk_device_manager_get_client_pointer (device_manager);
|
||||
|
||||
if (target == gdk_atom_intern_static_string ("TARGETS"))
|
||||
{
|
||||
GtkSelectionData selection_data;
|
||||
int n_atoms;
|
||||
GdkAtom *atoms;
|
||||
|
||||
selection_data.selection = GDK_NONE;
|
||||
selection_data.format = 32;
|
||||
selection_data.type = GDK_SELECTION_TYPE_ATOM;
|
||||
|
||||
n_atoms = gdk_wayland_device_get_selection_type_atoms (device, &atoms);
|
||||
selection_data.length = n_atoms;
|
||||
selection_data.data = atoms;
|
||||
|
||||
callback (gtkclipboard, &selection_data, user_data);
|
||||
return;
|
||||
}
|
||||
|
||||
/* When GTK+ requests text, it tries UTF8_STRING first and then
|
||||
* falls back to COMPOUND_TEXT and then STRING. We rewrite
|
||||
* UTF8_STRING to text/plain;charset=utf-8, and if that doesn't
|
||||
|
Loading…
Reference in New Issue
Block a user