-
Notifications
You must be signed in to change notification settings - Fork 343
wlr-data-control makes offers to clients that sent them #2406
Comments
If a client is listening for offers and sends an offer, it will block forever when it attempts to receive the offer and read from the file descriptor. This is because the offer is sent back to the client that sent it. Since the writing and reading ends are in the same client, it never has a chance to write, barring methods to work around this problem. Here we fix the problem by not making offers back to the client that sent them. Closes swaywm#2406.
If a client is listening for offers and sends an offer, it will block forever when it attempts to receive the offer and read from the file descriptor. This is because the offer is sent back to the client that sent it. Since the writing and reading ends are in the same client, it never has a chance to write (barring methods to work around this problem). Even if the client could read its own selection, it is pointless to do so. Here we fix the problem by not making offers back to the client that sent them. The protocol has been updated to reflect this change. Closes swaywm#2406.
If a client is listening for offers and sends an offer, it will block forever when it attempts to receive the offer and read from the file descriptor. This is because the offer is sent back to the client that sent it. Since the writing and reading ends are in the same client, it never has a chance to write (barring methods to work around this problem). Even if the client could read its own selection, it is pointless to do so. Here we fix the problem by not making offers back to the client that sent them. The protocol has been updated to reflect this change. Closes swaywm#2406.
I wrote an example program to demonstrate the problem. |
Disagree. Just as with core Wayland But note that "the same client" is somewhat loosely defined — several independent parts of a program could use the same Wayland connection (thus appearing as the same client to the compositor) without knowing much about each other; and one program can be broken up into multiple processes that use separate Wayland connections. So it's not as clear-cut. |
I was thinking about implementing a simple clipboard manager, that runs as a daemon process and saves the current selection so that it can be pasted after the client is destroyed. However with the current design, if the clipboard manager makes an offer when it gets an offer, the selection is canceled in the client. So e.g. with gtk clients, this makes the selection immediately become unselected. The clipboard manager could save the selection when it gets an offer and then make its own offer when the client is destroyed, but there is no offer_destroyed event. Do you think it would make sense to add an offer_destroyed event that fires when a client with an outstanding offer is destroyed so that such a clipboard manager daemon could make an offer in this case? Currently if text is highlighted and copied in a client and then it is closed, both 'clipboards' are empty and trying to middle-click-paste or regular-paste results in nothing being pasted.
This sounds like a good idea.
If there are such clients, I expect that they handle the messages given and dispatch them accordingly to other parts of itself. |
There's no However, I've long believed that |
Even if the offer comes from another client, said other client may block for a long time. Your client should perform non-blocking reads and writes instead. |
When using wlr-data-control protocol and listening for offers, any offer sent is also broadcast back to the client that sent it. This means that when the client tries to receive the data, it read()s from a fd that the same client has to write(). Of course, this causes the client to block forever. It doesn't really make sense to send something back to the client that it just sent. This makes me think that the protocol should state that sent sources are not rebroadcast back to the same client as offers. Thoughts?
The text was updated successfully, but these errors were encountered: