From 42bc208e6b0a35c68e9bb156c8d463d1a9a946b9 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Sat, 3 Oct 2015 17:54:37 +0300 Subject: Connector: store current encoder instead of crtc Also fixes a crash when there is no current encoder --- libkms++/connector.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'libkms++/connector.cpp') diff --git a/libkms++/connector.cpp b/libkms++/connector.cpp index 06703d6..d00f3c7 100644 --- a/libkms++/connector.cpp +++ b/libkms++/connector.cpp @@ -67,13 +67,15 @@ Connector::~Connector() void Connector::setup() { - if (m_priv->drm_connector->encoder_id != 0) { - auto enc = card().get_encoder(m_priv->drm_connector->encoder_id); - if (enc) - m_current_crtc = enc->get_crtc(); - } - - m_saved_crtc = m_current_crtc; + if (m_priv->drm_connector->encoder_id != 0) + m_current_encoder = card().get_encoder(m_priv->drm_connector->encoder_id); + else + m_current_encoder = 0; + + if (m_current_encoder) + m_saved_crtc = m_current_encoder->get_crtc(); + else + m_saved_crtc = 0; } void Connector::restore_mode() @@ -127,4 +129,13 @@ vector Connector::get_possible_crtcs() const return crtcs; } + +Crtc* Connector::get_current_crtc() const +{ + if (m_current_encoder) + return m_current_encoder->get_crtc(); + else + return 0; +} + } -- cgit v1.2.3