Commit Graph

31 Commits

Author SHA1 Message Date
Carlos Garnacho
de68968f89 wayland: Return the right type atom on gdk_selection_property_get()
We mistakenly forced the "STRING" type, which was able to confuse higher
layer helpers like gtk_selection_data_get_uris(). This fixes a crash
happening anytime a drop is attempted on a GtkPlacesSidebar.
2015-06-29 18:39:33 +02:00
Carlos Garnacho
50178ce014 wayland: Prepare against NULL selection owners on data_source requests
Currently, due to the lack of progress information in the Wayland DnD
protocol, we assume a DnD operation is finished after the first
data_source.send is finished (It's either that or leaving stuck grabs).

This however breaks previous assumptions that dest widgets can request
the data multiple times, even in response to GtkWidget::drag-motion.
This leaves us with a NULL owner for the DnD atom when we aren't
finished receiving wl_data_source events yet, causing a crash.

This commit fixes the crash, the behavior left is still far from
desirable though...
2015-06-29 18:39:05 +02:00
Carlos Garnacho
1178a0ac8b wayland: Split handling of clipboard/DnD data offers
We currently only hold the last offer received, which is wrong, as both
are independent and have different life cycles.

This means we have to store per-selection wl_data_offer and targets, and
maintain these as appropriate from the clipboard/DnD specific entry points.
2015-06-26 14:29:42 +02:00
Carlos Garnacho
350d555893 wayland: Fix compile warning in DnD/selection code
Introduced in my recent commits
2015-06-25 18:44:49 +02:00
Carlos Garnacho
6cc9b17429 wayland: Plug some memleaks in DnD/clipboard code
gdk_atom_name() return value must be freed, this code was consistently
not doing so...
2015-06-25 15:09:56 +02:00
Carlos Garnacho
342db27278 wayland: protect against unknown mimetype requests
This oddly can be reproduced with weston+weston-dnd, when dragging
anything from GTK+ into weston-dnd, it will insist on picking its
custom application/x-wayland-dnd-flower mimetype, and this request
forwarded by the compositor, even if GTK+ didn't announce it on
its wl_data_source mimetype list. (What should probably happen here
is that the request is silenced, and/or weston-dnd picks (null))

This should be harmless, we are leaking though the fd in that case,
because the emission of GdkEventSelection on an unhandled mimetype
results in NOP. In order to avoid this, we should check whether the
mimetype is supported at all on the backend code and possibly close
the fd, this involves storing these in the first place.

https://bugzilla.gnome.org/show_bug.cgi?id=751414
2015-06-24 23:52:50 +02:00
Carlos Garnacho
fb266a8876 wayland: Ensure we close the fd on all error paths in data_source.send
https://bugzilla.gnome.org/show_bug.cgi?id=751414
2015-06-24 23:52:50 +02:00
Carlos Garnacho
3bd7b2a6fb wayland: close() the selection fd if we didn't start writing yet
If the other peer requests data too fast (too rare/unlikely though),
we might receive multiple gdk_wayland_selection_request_target() calls
with no ending gdk_wayland_selection_check_write(), in which case the
fd is leaked as no GOutputStream was created to take over it.

https://bugzilla.gnome.org/show_bug.cgi?id=751414
2015-06-24 23:52:50 +02:00
Carlos Garnacho
5e7159413d wayland: Ensure we cancel previous selection writes before starting one
We weren't catching all the places where the AsyncWriteData operation
should be cancelled, which could happen if we repeatedly request the
same target on different fds.

https://bugzilla.gnome.org/show_bug.cgi?id=751414
2015-06-24 23:52:50 +02:00
Carlos Garnacho
69b5955108 wayland: Do not close the descriptor on async_write_data_free()
At the moment we create the AsyncWriteData, the ownership of the
fd is granted to the GOutputStream, and the fd set to -1, so at
this moment we're just silently getting EBADFD.

This partially reverts 25885ca600, the initialization of .fd
to -1 is valid and stays though.

https://bugzilla.gnome.org/show_bug.cgi?id=751414
2015-06-24 23:52:50 +02:00
Carlos Garnacho
25885ca600 wayland: Properly initialize/finalize where we store the data_source.send fd
The fd must be closed on async_write_data_free(), but we should also
initialize it to -1 so gdk_wayland_selection_check_write() doesn't wrongly
pick the stdin fd.

https://bugzilla.gnome.org/show_bug.cgi?id=751414
2015-06-24 16:42:06 +02:00
Carlos Garnacho
b84d9ea7ff wayland: Move DnD grab breaking function into gdkdevice-wayland.c
This has little to do with GdkDragContext, and a lot to do with
the GdkDevice that triggered it, seems to make more sense in
gdkdevice-wayland.c.
2015-06-02 18:09:49 +02:00
Matthias Clasen
393df9f7e1 wayland: Avoid compiler warnings
Fix warnings due to -Wdeclaration-after-statement and -Wshadow.
2015-06-02 09:08:14 -04:00
Carlos Garnacho
6c8c37abbb wayland: Silence warnings on clipboard data sending cancellation
During copy/paste, it may be common that we receive several property changes
around the selection atom, this results in warnings when cancelling the previous
write attempt. We already honor the last request properly, so we should just
cancel silently.
2015-03-19 16:05:04 +01:00
Carlos Garnacho
d5160bb950 wayland: Ensure we re-request the target if the fd changes
If we receive wl_data_source.target before .send, the target would already
be cached, but we'd take no action on the new fd.
2015-03-19 16:05:04 +01:00
Carlos Garnacho
a59fd4a9ad wayland: Don't accept the "TARGETS" target on the wl_data_offer
This is handled separately through the data already cached from the
wl_data_offer.offer handler, we can avoid this request entirely then.
2015-03-19 16:05:04 +01:00
Carlos Garnacho
dcfa55ac7e wayland: Fix thinko in wl_data_source.cancelled handler
The wl_data_source may be the clipboard's. Looking up the drag context in
order to get the display isn't going to fare well there. So, just use the
default display, and only look up the drag context when we know we need it.

https://bugzilla.gnome.org/show_bug.cgi?id=746386
2015-03-18 11:21:40 +01:00
Matthias Clasen
94c5d691df wayland: Formatting fixes 2015-02-28 00:02:30 -05:00
Jasper St. Pierre
c40ba85ace wayland: Don't use the default display
Pass a display in so that multi-display technology works.
2014-10-27 22:29:41 -07:00
Carlos Garnacho
69d9746708 wayland: write wl_data_offer data asynchronously
Currently writing wl_data_offer data into the fd is 1) synchronous, which
is noticeable when transferring large amounts of data, and 2) buggy, write()
error checking is done on the accumulator, breaking both the written data
accounting and error checking itself.

Fix both by making writes asynchonous through GOutputStream, the operation
is spun off and either finished, or cancelled if new data is stored in the
selection while the transfer is active.
2014-10-10 20:58:55 +02:00
Matthias Clasen
52578945bd Wayland: Fix various compiler warnings
Mostly missing declarations, missing statics and unused functions.
2014-09-05 20:41:06 -04:00
Carlos Garnacho
7b85a3417a wayland: Implement drag sources
The wl_data_source is retrieved from the selection object for the DnD
selection, and used to initiate a drag. When the drag is finished, a
button release or touch end event is synthesized to finish the DnD
operation after the compositor grab is gone.

https://bugzilla.gnome.org/show_bug.cgi?id=697855
2014-09-01 19:17:53 +02:00
Carlos Garnacho
f48b3cce02 wayland: Replace clipboard implementation
The wayland specific clipboard functions have been replaced by something
more similar to the hooking the win32 backend does, which allows for just
using the default GtkClipboard code in GTK+. As a consequence, the
wayland-specific GtkClipboard implementation is now gone.

https://bugzilla.gnome.org/show_bug.cgi?id=697855
2014-09-01 19:17:53 +02:00
Carlos Garnacho
7744799072 wayland: Implement drag/source side of selections
This has been made to work similarly to X11, requests for the data device
contents are notified through GDK_SELECTION_REQUEST events, the data stored
in the GDK_SELECTION property as a reaction to that event is then stored
into the wayland selection implementation, and written to the fd when
requested/available.

https://bugzilla.gnome.org/show_bug.cgi?id=697855
2014-09-01 19:17:53 +02:00
Carlos Garnacho
3b953041a9 wayland: Implement drop/destination side of selections
This implementation makes the destination side of selections work
similarly to X11's, gdk_selection_convert() triggers data fetching,
which is notified through GDK_SELECTION_NOTIFY events on arrival,
the buffered data is then available through gdk_selection_property_get().

https://bugzilla.gnome.org/show_bug.cgi?id=697855
2014-09-01 19:17:53 +02:00
Carlos Garnacho
32bf03c053 wayland: implement text_property_to_utf8_list()
Of some sort, this is enough to get text transfers on wayland, anything but
utf8 as plain/text should be pretty rare.

https://bugzilla.gnome.org/show_bug.cgi?id=697855
2014-09-01 19:17:53 +02:00
Rob Bradford
2928ffc7b1 wayland: Remove unhelpful debug message 2012-07-12 15:58:37 +01:00
Javier Jardón
9d0febc9a6 Change FSF Address 2012-02-27 17:06:11 +00:00
Kristian Høgsberg
1b918d1b93 wayland: Pretend selection works, print debug message 2011-02-10 10:54:10 -05:00
Kristian Høgsberg
541d5172dd Track 2.99.3 API changes 2011-02-08 08:12:59 -05:00
Kristian Høgsberg
590f3dfa1f Add Wayland backend 2011-02-05 16:11:54 -05:00