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

backend/session: misc. refactoring, replace CanGraphical with udev #2465

Merged
merged 9 commits into from
Nov 19, 2020

Conversation

emersion
Copy link
Member

@emersion emersion commented Nov 6, 2020

See individual commits.

This PR refactors wlr_session to prepare support for GPU hotplug. cc @neon64

  • The session API doesn't deal with FDs anymore, wlr_device is used instead. This allows callers to directly listen on wlr_device events. This will be useful for a future "remove" event.
  • A new add_drm_card event is introduced. It's used to replace the logind-specific CanGraphical property.
  • Signals are renamed and moved into an embedded events struct, for consistency with the rest of wlroots.

Breaking changes:

  • wlr_drm_backend_create takes a wlr_device instead of a DRM FD
  • wlr_device.signal has been replaced by wlr_device.events.change
  • wlr_session.session_signal has been replaced by wlr_session.events.active
  • wlr_session_open_file and wlr_session_close_file now take a wlr_device instead of a FD
  • wlr_session_find_gpus now fills an array of wlr_device pointers instead of an array of FDs

When wlr_session_open_file fails, don't return the FD, otherwise the
caller will think the call succeeded.
Instead of operating on FDs in {open,close}_device, operate on
wlr_devices. This avoids the device lookup in wlr_session and allows
callers to have access to wlr_device fields.

For now, we use it to remove wlr_session_signal_add and replace it with
a more idiomatic wlr_session.events.change field. In the future, other
events will be added.
We're only interested in card devices. The loop over wlr_session.devices
would take care of ignoring non-card events, but a future patch will
listen to udev "add" events as well.
This is triggered when a new DRM card is added.

An easy way to test this patch is `modprobe vkms`.
Wait for a DRM device if none is found in wlr_session_find_gpus. This
can happen if the compositor is loaded before the display kernel driver.

This supersedes the logind CanGraphical property.

To test, e.g. with i915 and sway:

    rmmod -f i915
    sway &
    modprobe i915

Closes: swaywm#2093
We now use udev to wait for DRM card devices.

This reverts commit 3ebf079.
This is more idiomatic wlroots API. The new name makes it clear that the
signal is emitted when wlr_session.active changes.
This makes it easier to figure out how wlroots selected the session.
If a GPU doesn't show up in 10s, bail out and return zero GPUs.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking Breaking change in public API
Development

Successfully merging this pull request may close these issues.

1 participant