swaywm / sway

i3-compatible Wayland compositor
https://swaywm.org
MIT License
14.42k stars 1.1k forks source link

seat detach command or only one seat per device #3491

Open YaLTeR opened 5 years ago

YaLTeR commented 5 years ago

Sway Version: 1.0-beta.2-254-g42f8a038 (Jan 22 2019, branch 'makepkg')

Attaching my keyboard to multiple seats (running swaymsg seat seat1 attach 1:1:AT_Translated_Set_2_keyboard, swaymsg seat seat2 attach 1:1:AT_Translated_Set_2_keyboard) results in no clear way of reverting this action. Either a detach command would be helpful or just not allowing one device to be attached to multiple seats at once (so attach would change the device seat rather than adding it).

emersion commented 5 years ago

There is an opened PR about this: https://github.com/swaywm/sway/pull/3045

TitouanT commented 3 years ago

The PR mentionned by @emersion is closed (#3045). Are there any news on the matter ? I think a detach command would be useful to completely disable a device. And having a device belonging to more than one seat don't make much sense.

Also is it possible, without removing any devices from it, to remove a capability from a seat ?

emersion commented 3 years ago

Are there any news on the matter ?

The PR is waiting for someone to pick it up and finish the work.

I think a detach command would be useful to completely disable a device.

A detach command wouldn't disable any device.

Also is it possible, without removing any devices from it, to remove a capability from a seat ?

No, this doesn't make sense.

TitouanT commented 3 years ago

The PR is waiting for someone to pick it up and finish the work.

Ok, I have time tomorrow, I'll see what I can do. I am really intersted in wayland and sway and I'd love to contribute in some way.

A detach command wouldn't disable any device.

Wouldn't it ? I mean, if it is not attached to any seat, then it wouldn't be able to interact with any GUI, would it ? I might not have understood what seats are, but from the definition I have read, I was imagining that a device who doesn't belong to any seat would be as good as plugged out.

Also is it possible, without removing any devices from it, to remove a capability from a seat ?

No, this doesn't make sense.

Ok, I thought this could be an intersting mechanic (for a game maybe?) to be able to give let's say cursor capability to two seats in a mutually exclusive manner.

emersion commented 3 years ago

Ok, I have time tomorrow, I'll see what I can do. I am really intersted in wayland and sway and I'd love to contribute in some way.

Cool, feel free to join #sway-devel on Freenode if you have questions!

I mean, if it is not attached to any seat, then it wouldn't be able to interact with any GUI, would it ?

Hmm. Right. Since a device can be attached to multiple seats, I was actually thinking that a device would always be attached to at least one seat. (There's already a way to disable a device, input XXX events disable.)

But maybe we should allow devices to be completely detached. We need to think how both options would affect common seat use-cases.

Ok, I thought this could be an intersting mechanic (for a game maybe?) to be able to give let's say cursor capability to two seats in a mutually exclusive manner.

I'd really prefer not to make the capability logic more complicated here. But I don't really understand your use-case here, can you elaborate?

emersion commented 3 years ago

I think a generally useful command would be something like seat <name> attach --detach-others <input_identifier>, which would move the input device to a single seat (suggestions for the option name welcome).

TitouanT commented 3 years ago

Cool, feel free to join #sway-devel on Freenode if you have questions!

I just did :)

I'd really prefer not to make the capability logic more complicated here. But I don't really understand your use-case here, can you elaborate?

For example, disabling the pointer capability from a seat would be the same as going through every devices like touchpads, and mouses from that seat and to disable them one by one. What I was really thinking about was a place where I could store disabled devices, like a nullSeat or something in those lines.

I think a generally useful command would be something like seat attach --detach-others

The --detach-(from?-)others (or --exclusive ?) flag would be useful, but not very general. Because it implies that a multi-seat device is still possible and therefore in order to detach it from one seat, the only way would be to:

emersion commented 3 years ago

For example, disabling the pointer capability from a seat would be the same as going through every devices like touchpads, and mouses from that seat and to disable them one by one.

Ah. So seat seat0 detach type:pointer or something like that?

The --detach-(from?-)others (or --exclusive ?) flag would be useful, but not very general.

Yes, just a helper.

specious commented 3 years ago

Ok, I thought this could be an intersting mechanic (for a game maybe?) to be able to give let's say cursor capability to two seats in a mutually exclusive manner.

That could be a great idea. However, an application can receive and interpret device events directly from /dev/input, with or without the help of a library like libinput.

How the sway compositor interprets these events is not crucial here.

emersion commented 3 years ago

an application can receive and interpret device events directly from /dev/input, with or without the help of a library like libinput

No, opening these devices requires root privileges.

specious commented 3 years ago

Oh, I see.

On the system I'm using right now (arch, default permission structure) users in group input as well as root can read from events in /dev/input.

I suppose it makes sense that raw access to these devices would not be universally unrestricted.