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

seat: allow clients to bind to seat multiple times #1031

Merged
merged 1 commit into from
Jun 4, 2018
Merged

seat: allow clients to bind to seat multiple times #1031

merged 1 commit into from
Jun 4, 2018

Conversation

martinetd
Copy link
Member

@martinetd martinetd commented Jun 3, 2018

This lets clients bind to a seat multiple times by re-using the existing
wlr_seat_client whenever a duplicate request happens.
Previously, an independant wlr_seat_client would be created and only
events from one would be processed.

Fixes #1023.

FWIW I'm not 100% happy with the style (new_seat_client bool and the need for a new function in the API, and that function's name), but at least it seems to work.
Cc @Ongy @Timidger as API changes, even if I didn't need to change anything to rootston/sway, it's just a new helper function change in the wlr_seat_client struct

@@ -282,6 +307,20 @@ struct wlr_seat_client *wlr_seat_client_for_wl_client(struct wlr_seat *wlr_seat,
return NULL;
}

struct wl_client *wl_client_for_wlr_seat_client(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already wlr_seat_client->client

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. That removes one thorn, I totally missed that. Thanks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(force pushed)

struct wl_client *client;
struct wlr_seat *seat;

// lists of wl_resource
struct wl_list binds;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like a lot that there are two levels of lists. Why not create one wlr_seat_client per bind?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you call two levels of lists? There already are plenty of lists in wlr_seat_client.
On the other hand, creating one wlr_seat_client per bind will make us iterate over all the binds everywhere we want to notify the client about something, that's a much bigger code change that would break compositor compat (that is fine) and feels less practical to use.
Unless there's any reason to treat one bind differently from the other I'd rather keep it as simple as possible from an interface point of view

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll think about it. In the meantime, can you rename it to resources? We don't use the term "bind" anywhere.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, looked around and we're not consistent at all. The one that comes up most is wl_resources but we have resources, client_resources...

I personally don't like to say just resources as everything is resources, a few lines below (thanks github for showing context!!!) are "resources" to pointers, keyboards etc.

Anyway, renaming for now, but this might need a separate discussion.

BTW I think you're thinking too much, this is basically just what I said in #1023 - or did you understand something else in my comment?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, read it too quickly.

@emersion
Copy link
Member

emersion commented Jun 4, 2018

Can you confirm it fixes firefox on wayland?

I personally don't like to say just resources as everything is resources, a few lines below (thanks github for showing context!!!) are "resources" to pointers, keyboards etc.

Yeah, but the struct is named wlr_seat_client, so it makes sense that a resource field contains a wl_seat.

@martinetd
Copy link
Member Author

Can you confirm it fixes firefox on wayland?

Yes it does. Well, it doesn't work great because of no popup, but there's input.

Yeah, but the struct is named wlr_seat_client, so it makes sense that a resource field contains a wl_seat.

Well, sure, until it's created as struct wlr_seat_client *client and then client->resource is a wl_seat (thanksfully nobody tried to access that field with that naming until now, but we do have some of that naming)
Anyway, I'm just nitpicking at this point, it's more annoying to me that we have some wl_resources some resources and some others, I'll open an issue for that later

@emersion
Copy link
Member

emersion commented Jun 4, 2018

Yes it does. Well, it doesn't work great because of no popup, but there's input.

Good. Is the popup issue a firefox issue or a wlroots issue?

Anyway, I'm just nitpicking at this point, it's more annoying to me that we have some wl_resources some resources and some others, I'll open an issue for that later

+1

}
seat_client->wl_resource =

struct wl_resource *wl_resource =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can move this block before the previous one and remove new_seat_client?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea.
How can we cleanly undo a wl_resource_create if the calloc fails, though? just destroy it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, wl_resource_destroy should do it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, force pushed.

Copy link
Member Author

@martinetd martinetd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good. Is the popup issue a firefox issue or a wlroots issue?

Unsure yet, I tried to test just after you posted and got rootston stuck in a loop in wlr_surface_get_root_surface because subsurface->surface == surface and it gets stuck, so either the logic is wrong or we need an anti-looping check (and then, is one level enough e.g. A->B->A or would we need something more complex for A->B->C->D->B->... that would suck)
The first time it didn't get stuck though, but it looks the the subsurface appeared below the firefox window (z-axis below, e.g. making firefox small with a large popup I'd see the bottom of the popup but the top would be hidden by FF)

But for either of these problems, I didn't check if what FF does is correct.

}
seat_client->wl_resource =

struct wl_resource *wl_resource =
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea.
How can we cleanly undo a wl_resource_create if the calloc fails, though? just destroy it?

@agx
Copy link
Contributor

agx commented Jun 4, 2018

Ah...I've seen something similar in phosh when binding to a seat multiple times

https://source.puri.sm/Librem5/phosh/blob/master/src/phosh.c#L634

I can try the patches later this week.

This lets clients bind to a seat multiple times by re-using the existing
wlr_seat_client whenever a duplicate request happens.
Previously, an independant wlr_seat_client would be created and only
events from one would be processed.

Fixes #1023.
@martinetd
Copy link
Member Author

@agx: Cool! I'm sure the other problems with firefox-wayland are different anyway so should be separate, but this can probably wait until you've had time to test to be sure.

@emersion emersion merged commit 7896641 into swaywm:master Jun 4, 2018
@emersion
Copy link
Member

emersion commented Jun 4, 2018

Thanks!

@agx
Copy link
Contributor

agx commented Jun 4, 2018 via email

@emersion
Copy link
Member

emersion commented Jun 4, 2018

I did not look at the code but your patch breaks binding wl_seat multiple times in phosh.

Can you elaborate?

@martinetd martinetd deleted the multibind-seat branch June 5, 2018 00:26
@agx
Copy link
Contributor

agx commented Jun 5, 2018 via email

@emersion
Copy link
Member

emersion commented Jun 5, 2018

Ahah, got it, thanks for the feedback!

agx added a commit to agx/phosh that referenced this pull request Sep 30, 2018
The corresponding issue in wlroots was fixed by

  swaywm/wlroots#1031
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.

None yet

3 participants