Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

[WIP] wlr_primary_selection: Allow multiple offers per source #1113

Closed
wants to merge 1 commit into from
Closed

[WIP] wlr_primary_selection: Allow multiple offers per source #1113

wants to merge 1 commit into from

Conversation

martinetd
Copy link
Member

Create as many offers as there are selection devices, so that we do
not send a client multiple times the same "new_id" offer (which
would make it crash)

Note something is weird with this and X11; once I've selected something in firefox then pastes to X11 do not work anymore (even from other wayland apps); I don't understand what though so could use some help with that.

Part of #1041 (this is not complete as it only does primary_selection, data_source needs a similar fix... but data source uses source->offer everywhere (like in drag n drop as well) so such an approach is going to be a royal pain)

Cc @aereaux as he said he would work on this a couple of weeks ago, if you want to take over please do (I can find something else to do :P); or if you just have thought about it and have an opinion it's welcome as well :)

Create as many offers as there are selection devices, so that we do
not send a client multiple times the same "new_id" offer (which
would make it crash)

Part of #1041
@martinetd
Copy link
Member Author

BTW if there is no client in wleird that binds to the seat twice and deals with data devices I think it would be a nifty thing to add (I guess saying that means I'm welcome to do it... But it can't hurt to try, I already have a weird client called firefox here :P)

@emersion
Copy link
Member

emersion commented Jul 5, 2018

Maybe offer should have multiple resources instead?

@martinetd
Copy link
Member Author

Maybe offer should have multiple resources instead?

Hm, that'll certainly be less code change for wlr_data_device.
It does have the problem that we still need to match 1-to-1 the selection/data device to the resource.
Technically we could just say "I guarantee that the list of offer resources is in the same order as the list of data device resources" but that seems very fragile, so that means allocating one more wrapper struct with just offer resource+data device resource+link; that feels just like the same as what I did with offers just now.

@emersion
Copy link
Member

emersion commented Jul 5, 2018

It does have the problem that we still need to match 1-to-1 the selection/data device to the resource.

Right, I was thinking that using wl_resource_get_client would be enough, but it won't :(

@martinetd
Copy link
Member Author

We could set the offer's resource user data to the device, and use the offer's resource link to store only that list of resource in the wlr_x_offer struct.

That would spare making that extra wrapper item, I'll try that.

@martinetd
Copy link
Member Author

Ah, we already use that user data to store a pointer to the wlr offer struct in the wl_resource offer, so I can't use it for the device :/

Tricky.

@martinetd
Copy link
Member Author

Just a note here as I had totally forgotten about this until emersion mentioned it on IRC yesterday when someone asked about firefox-wayland.

Part of the reason I forgot is that I'm a bit stale on ideas for what to do, this implementation pattern works for firefox but will be quite a bit of churn in wlr_data_device if I take the same approach.
I haven't figured out the problem of pasting to X11 either, but I can't say I've spent time on it since so I can't blame anyone for that one :P

I'll be afk the next couple of days regardless, but if there is some form of agreement on the direction to take I'll look at it when I'm back :)

emersion added a commit to emersion/wlroots that referenced this pull request Nov 21, 2018
When a client was creating multiple data devices for the same seat, we were
only creating one resource. This is a protocol error.

Instead, create one offer per data device.

This commit also makes offers inert when their source is destroyed.

Fixes part of swaywm#1041
Supersedes swaywm#1113
emersion added a commit to emersion/wlroots that referenced this pull request Nov 21, 2018
When a client was creating multiple data devices for the same seat, we were
only creating one resource. This is a protocol error.

Instead, create one offer per data device.

This commit also makes offers inert when their source is destroyed.

Fixes part of swaywm#1041
Supersedes swaywm#1113
@martinetd
Copy link
Member Author

Superseded by #1380; thanks!

@martinetd martinetd closed this Nov 21, 2018
@martinetd martinetd deleted the multiple-offers-source branch December 13, 2018 00:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants