1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-30 18:49:31 +00:00

Restore previous strut behavior

This commit is contained in:
Marc Aldorasi 2024-06-08 20:49:33 -04:00 committed by Brenden Matthews
parent f88b50d21a
commit 9f830224e5
2 changed files with 26 additions and 51 deletions

View File

@ -430,21 +430,13 @@ struct rect {
/// @brief Rectangle width. /// @brief Rectangle width.
/// @return width of this rectangle. /// @return width of this rectangle.
inline T width() const { inline T width() const {
if constexpr (Kind == rect_kind::SIZED) { return size().x();
return this->m_other.x();
} else {
return this->m_other.x() + this->m_pos.x();
}
} }
/// @brief Rectangle height. /// @brief Rectangle height.
/// @return height of this rectangle. /// @return height of this rectangle.
inline T height() const { inline T height() const {
if constexpr (Kind == rect_kind::SIZED) { return size().y();
return this->m_other.y();
} else {
return this->m_other.y() + this->m_pos.y();
}
} }
/// @brief Returns rectangle component at `index`. /// @brief Returns rectangle component at `index`.

View File

@ -1144,50 +1144,33 @@ void set_struts(alignment align) {
int display_width = workarea.width(); int display_width = workarea.width();
int display_height = workarea.height(); int display_height = workarea.height();
switch (horizontal_alignment(align)) { switch (align) {
case axis_align::START: case alignment::TOP_LEFT:
sizes[*x11_strut::LEFT] = std::clamp( case alignment::TOP_RIGHT:
window.geometry.x() + window.geometry.end_x(), 0, display_width); case alignment::TOP_MIDDLE:
sizes[*x11_strut::LEFT_START_Y] = sizes[*x11_strut::TOP] = std::clamp(window.geometry.end_y(), 0, display_height);
std::clamp(window.geometry.y(), 0, display_height); sizes[*x11_strut::TOP_START_X] = std::clamp(window.geometry.x(), 0, display_width);
sizes[*x11_strut::LEFT_END_Y] = std::clamp( sizes[*x11_strut::TOP_END_X] = std::clamp(window.geometry.end_x(), 0, display_width);
window.geometry.y() + window.geometry.height(), 0, display_height);
break; break;
case axis_align::END: case alignment::BOTTOM_LEFT:
sizes[*x11_strut::RIGHT] = case alignment::BOTTOM_RIGHT:
std::clamp(display_width - window.geometry.x(), 0, display_width); case alignment::BOTTOM_MIDDLE:
sizes[*x11_strut::RIGHT_START_Y] = sizes[*x11_strut::BOTTOM] = display_height - std::clamp(window.geometry.y(), 0, display_height);
std::clamp(window.geometry.y(), 0, display_height); sizes[*x11_strut::BOTTOM_START_X] = std::clamp(window.geometry.x(), 0, display_width);
sizes[*x11_strut::RIGHT_END_Y] = std::clamp( sizes[*x11_strut::BOTTOM_END_X] = std::clamp(window.geometry.end_x(), 0, display_width);
window.geometry.y() + window.geometry.height(), 0, display_height); break;
case alignment::MIDDLE_LEFT:
sizes[*x11_strut::LEFT] = std::clamp(window.geometry.end_x(), 0, display_width);
sizes[*x11_strut::LEFT_START_Y] = std::clamp(window.geometry.y(), 0, display_height);
sizes[*x11_strut::LEFT_END_Y] = std::clamp(window.geometry.end_y(), 0, display_height);
break;
case alignment::MIDDLE_RIGHT:
sizes[*x11_strut::RIGHT] = display_width - std::clamp(window.geometry.x(), 0, display_width);
sizes[*x11_strut::RIGHT_START_Y] = std::clamp(window.geometry.y(), 0, display_height);
sizes[*x11_strut::RIGHT_END_Y] = std::clamp(window.geometry.end_y(), 0, display_height);
break; break;
case axis_align::MIDDLE:
switch (vertical_alignment(align)) {
case axis_align::START:
sizes[*x11_strut::TOP] =
std::clamp(window.geometry.y() + window.geometry.height(), 0,
display_height);
sizes[*x11_strut::TOP_START_X] =
std::clamp(window.geometry.x(), 0, display_width);
sizes[*x11_strut::TOP_END_X] =
std::clamp(window.geometry.x() + window.geometry.width(), 0,
display_width);
break;
case axis_align::END:
sizes[*x11_strut::BOTTOM] = std::clamp(
display_height - window.geometry.y(), 0, display_height);
sizes[*x11_strut::BOTTOM_START_X] =
std::clamp(window.geometry.x(), 0, display_width);
sizes[*x11_strut::BOTTOM_END_X] =
std::clamp(window.geometry.x() + window.geometry.width(), 0,
display_width);
break;
case axis_align::MIDDLE:
// can't reserve space in middle of the screen
default:
break;
}
default: default:
// can't reserve space in middle of the screen
break; break;
} }