wlroots/include/backend/drm/iface.h
Johan Malm 175c20d954 Revert removal of automatic drm reset on VT switch
...on the basis that it reduces user-space breakage with respect to
layer-shell clients disappearing on suspend/resume and on VT change.

Revert the following two commits:

- 1edd5e2  "backend/drm: Remove reset from interface"
- 0f255b4  "backend/drm: Remove automatic reset on VT switch"

This it not intended to be reverted on the `master` branch. Instead, the
next wlroots release is anticipated to handle the situation differently,
possibly by splitting some objects and leaving output-related wl_globals
which have been announced to clients. See discussions on [issue-3944].

[issue-3944]: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3944#note_3030632

Background:

With [MR-4878] on wlroots-0.19.0, the DRM backend destroys/recreates
outputs on VT switch and in some cases on suspend/resume too. The reason
for this change was that (i) the KMS state is undefined when a VT is
switched away; and (ii) the previous outputs had issues with restoration,
particularly when the output configuration had changed whilst switched
away. This change causes two issues for users:

- Some layer-shell clients do not re-appear on output re-connection, or
  may appear on a different output. Whilst this has always been the case,
  it will now also happen in said situations. It is technically possible
  for layer-shell clients to deal with this more thoughtfully by handling
  the new-output and surface-destroy signals to achieve desired
  behaviours, but such changes take time and meanwhile Desktop Environment
  teams and other users consider this a serious regression.

- Some Gtk clients issue critical warnings on some compositors as they
  assume that at least one output is always available. This will be fixed
  in `Gtk-3.24.50` and is believed to be a harmless warning,

[MR-4878]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4878

Testing:

1. This reversion has been tested with [conky] and [GlassyClock]. With the
reversion applied, the clients remain visible after VT switching.
2. It was also tested with labwc on tty1; and sway on tty2. No adverse
affects were observed when changing output scales on either compositor.

[conky]: https://github.com/brndnmtthws/conky
[GlassyClock]: https://github.com/tsujan/GlassyClock
2025-08-03 13:01:45 +01:00

45 lines
1.4 KiB
C

#ifndef BACKEND_DRM_IFACE_H
#define BACKEND_DRM_IFACE_H
#include <stdbool.h>
#include <stdint.h>
#include <pixman.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
struct wlr_drm_backend;
struct wlr_drm_connector;
struct wlr_drm_crtc;
struct wlr_drm_device_state;
struct wlr_drm_connector_state;
struct wlr_drm_fb;
struct wlr_drm_page_flip;
// Used to provide atomic or legacy DRM functions
struct wlr_drm_interface {
bool (*init)(struct wlr_drm_backend *drm);
void (*finish)(struct wlr_drm_backend *drm);
bool (*commit)(struct wlr_drm_backend *drm,
const struct wlr_drm_device_state *state,
struct wlr_drm_page_flip *page_flip, uint32_t flags, bool test_only);
// Turn off everything
bool (*reset)(struct wlr_drm_backend *drm);
};
extern const struct wlr_drm_interface atomic_iface;
extern const struct wlr_drm_interface legacy_iface;
extern const struct wlr_drm_interface liftoff_iface;
bool drm_legacy_crtc_set_gamma(struct wlr_drm_backend *drm,
struct wlr_drm_crtc *crtc, size_t size, uint16_t *lut);
bool create_fb_damage_clips_blob(struct wlr_drm_backend *drm,
int width, int height, const pixman_region32_t *damage, uint32_t *blob_id);
bool drm_atomic_reset(struct wlr_drm_backend *drm);
bool drm_atomic_connector_prepare(struct wlr_drm_connector_state *state,
bool modeset);
void drm_atomic_connector_apply_commit(struct wlr_drm_connector_state *state);
void drm_atomic_connector_rollback_commit(struct wlr_drm_connector_state *state);
#endif