Commit e4236e02 authored by Frederik Gladhorn's avatar Frederik Gladhorn

Simplify getting edid in xrandr backend

Summary: XRandR::outputEdid is used in only one place, let it return a byte array directly.

Reviewers: #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: zzag, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D14044
parent 06c0513f
......@@ -251,8 +251,9 @@ quint8* XRandR::getXProperty(xcb_randr_output_t output, xcb_atom_t atom, size_t
return result;
}
quint8 *XRandR::outputEdid(xcb_randr_output_t outputId, size_t &len)
QByteArray XRandR::outputEdid(xcb_randr_output_t outputId)
{
size_t len = 0;
quint8 *result;
auto edid_atom = XCB::InternAtom(false, 4, "EDID")->atom;
......@@ -266,16 +267,14 @@ quint8 *XRandR::outputEdid(xcb_randr_output_t outputId, size_t &len)
result = XRandR::getXProperty(outputId, edid_atom, len);
}
if (result) {
QByteArray edid;
if (result != nullptr) {
if (len % 128 == 0) {
return result;
} else {
len = 0;
delete[] result;
edid = QByteArray((char *) result, len);
}
delete[] result;
}
return nullptr;
return edid;
}
xcb_randr_get_screen_resources_reply_t* XRandR::screenResources()
......
......@@ -52,7 +52,7 @@ class XRandR : public KScreen::AbstractBackend
bool isValid() const override;
QByteArray edid(int outputId) const override;
static quint8 *outputEdid(xcb_randr_output_t outputId, size_t &len);
static QByteArray outputEdid(xcb_randr_output_t outputId);
static xcb_randr_get_screen_resources_reply_t* screenResources();
static xcb_screen_t* screen();
static xcb_window_t rootWindow();
......
......@@ -105,16 +105,8 @@ KScreen::Output::Rotation XRandROutput::rotation() const
QByteArray XRandROutput::edid() const
{
if (m_edid.isNull()) {
size_t len;
quint8 *data = XRandR::outputEdid(m_id, len);
if (data) {
m_edid = QByteArray((char *) data, len);
delete[] data;
} else {
m_edid = QByteArray();
}
m_edid = XRandR::outputEdid(m_id);
}
return m_edid;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment