aboutsummaryrefslogtreecommitdiff
path: root/backend/drm
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2024-02-14 16:50:54 +0100
committerSimon Ser <contact@emersion.fr>2024-02-14 17:13:25 +0100
commitfeb54979c0940655e36119c63e18a9ee72cc03b0 (patch)
treec397f0fa105b95fd67b63e340abcfa026abcb241 /backend/drm
parentc397515ee5a1cc2df501f4bc522da32dcf2932dc (diff)
backend/drm: extract logic to build current connector state
Diffstat (limited to 'backend/drm')
-rw-r--r--backend/drm/backend.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/backend/drm/backend.c b/backend/drm/backend.c
index ebd727b8..84ae3738 100644
--- a/backend/drm/backend.c
+++ b/backend/drm/backend.c
@@ -95,6 +95,24 @@ struct wlr_backend *wlr_drm_backend_get_parent(struct wlr_backend *backend) {
return drm->parent ? &drm->parent->backend : NULL;
}
+static void build_current_connector_state(struct wlr_output_state *state,
+ struct wlr_drm_connector *conn) {
+ bool enabled = conn->status != DRM_MODE_DISCONNECTED && conn->output.enabled;
+
+ wlr_output_state_init(state);
+ wlr_output_state_set_enabled(state, enabled);
+ if (!enabled) {
+ return;
+ }
+
+ if (conn->output.current_mode != NULL) {
+ wlr_output_state_set_mode(state, conn->output.current_mode);
+ } else {
+ wlr_output_state_set_custom_mode(state,
+ conn->output.width, conn->output.height, conn->output.refresh);
+ }
+}
+
static void handle_session_active(struct wl_listener *listener, void *data) {
struct wlr_drm_backend *drm =
wl_container_of(listener, drm, session_active);
@@ -125,19 +143,8 @@ static void handle_session_active(struct wl_listener *listener, void *data) {
struct wlr_drm_connector *conn;
wl_list_for_each(conn, &drm->connectors, link) {
- bool enabled = conn->status != DRM_MODE_DISCONNECTED && conn->output.enabled;
-
struct wlr_output_state state;
- wlr_output_state_init(&state);
- wlr_output_state_set_enabled(&state, enabled);
- if (enabled) {
- if (conn->output.current_mode != NULL) {
- wlr_output_state_set_mode(&state, conn->output.current_mode);
- } else {
- wlr_output_state_set_custom_mode(&state,
- conn->output.width, conn->output.height, conn->output.refresh);
- }
- }
+ build_current_connector_state(&state, conn);
if (!drm_connector_commit_state(conn, &state)) {
wlr_drm_conn_log(conn, WLR_ERROR, "Failed to restore state after VT switch");
}