fix(xbacklight): Allow larger property values
Not all backlight values are within 8 bit range so do not truncate property values
This commit is contained in:
parent
ee92c30ff4
commit
83ae9f6435
@ -74,28 +74,29 @@ namespace randr_util {
|
|||||||
inline void get_backlight_range(connection& conn, const monitor_t& mon, backlight_values& dst) {
|
inline void get_backlight_range(connection& conn, const monitor_t& mon, backlight_values& dst) {
|
||||||
auto reply = conn.query_output_property(mon->randr_output, Backlight);
|
auto reply = conn.query_output_property(mon->randr_output, Backlight);
|
||||||
|
|
||||||
|
dst.min = 0;
|
||||||
|
dst.max = 0;
|
||||||
|
|
||||||
if (!reply->range || reply->length != 2)
|
if (!reply->range || reply->length != 2)
|
||||||
reply = conn.query_output_property(mon->randr_output, BACKLIGHT);
|
reply = conn.query_output_property(mon->randr_output, BACKLIGHT);
|
||||||
|
|
||||||
if (!reply->range || reply->length != 2)
|
if (!reply->range || reply->length != 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto range = reply.valid_values().begin();
|
auto range = reply.valid_values().begin();
|
||||||
|
|
||||||
dst.min = *range++;
|
dst.min = static_cast<uint32_t>(*range++);
|
||||||
dst.max = *range;
|
dst.max = static_cast<uint32_t>(*range);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void get_backlight_value(connection& conn, const monitor_t& mon, backlight_values& dst) {
|
inline void get_backlight_value(connection& conn, const monitor_t& mon, backlight_values& dst) {
|
||||||
auto reply = conn.get_output_property(mon->randr_output, Backlight, XCB_ATOM_NONE, 0, 4, 0, 0);
|
auto reply = conn.get_output_property(mon->randr_output, Backlight, XCB_ATOM_NONE, 0, 4, 0, 0);
|
||||||
|
|
||||||
if (!reply->num_items)
|
if (reply->num_items != 1 || reply->format != 32 || reply->type != XCB_ATOM_INTEGER)
|
||||||
reply = conn.get_output_property(mon->randr_output, BACKLIGHT, XCB_ATOM_NONE, 0, 4, 0, 0);
|
reply = conn.get_output_property(mon->randr_output, BACKLIGHT, XCB_ATOM_NONE, 0, 4, 0, 0);
|
||||||
|
if (reply->num_items == 1 && reply->format == 32 && reply->type == XCB_ATOM_INTEGER)
|
||||||
if(!reply->num_items)
|
dst.val = *reinterpret_cast<uint32_t*>(xcb_randr_get_output_property_data(reply.get().get()));
|
||||||
return;
|
else
|
||||||
|
dst.val = 0;
|
||||||
dst.val = *reply.data().begin();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ namespace modules {
|
|||||||
// Query for the new backlight value
|
// Query for the new backlight value
|
||||||
auto& bl = m_output->backlight;
|
auto& bl = m_output->backlight;
|
||||||
randr_util::get_backlight_value(m_connection, m_output, bl);
|
randr_util::get_backlight_value(m_connection, m_output, bl);
|
||||||
m_percentage = math_util::percentage<float>(bl.val, bl.min, bl.max);
|
m_percentage = math_util::percentage(bl.val, bl.min, bl.max);
|
||||||
|
|
||||||
// Update label tokens
|
// Update label tokens
|
||||||
if (m_label) {
|
if (m_label) {
|
||||||
|
Loading…
Reference in New Issue
Block a user