-
Notifications
You must be signed in to change notification settings - Fork 342
seat: allow clients to bind to seat multiple times #1031
Conversation
types/seat/wlr_seat.c
Outdated
@@ -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( |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(force pushed)
include/wlr/types/wlr_seat.h
Outdated
struct wl_client *client; | ||
struct wlr_seat *seat; | ||
|
||
// lists of wl_resource | ||
struct wl_list binds; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Can you confirm it fixes firefox on wayland?
Yeah, but the struct is named |
Yes it does. Well, it doesn't work great because of no popup, but there's input.
Well, sure, until it's created as |
Good. Is the popup issue a firefox issue or a wlroots issue?
+1 |
types/seat/wlr_seat.c
Outdated
} | ||
seat_client->wl_resource = | ||
|
||
struct wl_resource *wl_resource = |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, force pushed.
There was a problem hiding this 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.
types/seat/wlr_seat.c
Outdated
} | ||
seat_client->wl_resource = | ||
|
||
struct wl_resource *wl_resource = |
There was a problem hiding this comment.
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?
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.
@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. |
Thanks! |
Hi,
On Mon, Jun 04, 2018 at 06:37:08AM -0700, Dominique Martinet wrote:
***@***.***: 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.
I did not look at the code but your patch breaks binding wl_seat
multiple times in phosh. Without your patch there's simply no input at
all, works fine with your patch applied.
|
Can you elaborate? |
Hi,
On Mon, Jun 04, 2018 at 04:40:01PM +0000, emersion wrote:
I did not look at the code but your patch breaks binding wl_seat
multiple times in phosh.
Can you elaborate?
This meant to read:
I did not look at the code but your patch *un*breaks binding wl_seat
multiple times in phosh.
|
Ahah, got it, thanks for the feedback! |
The corresponding issue in wlroots was fixed by swaywm/wlroots#1031
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 functionchange in thewlr_seat_client
struct