Skip to content

Commit

Permalink
Make corner panel favor horizontal strut sides
Browse files Browse the repository at this point in the history
Did this to abide by: A "corner" panel that does not extend for the full
length of a screen border SHOULD only set one strut.

Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
  • Loading branch information
Caellian committed Apr 24, 2024
1 parent a2df27a commit cb6adb7
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions src/x11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1116,29 +1116,7 @@ void set_struts(alignment align) {
Atom strut = ATOM(_NET_WM_STRUT);
if (strut != None) {
long sizes[STRUT_COUNT] = {0};
int i;

switch (vertical_alignment(align)) {
case axis_align::START:
sizes[*x11_strut::TOP] =
std::clamp(window.y + window.height, 0, display_height);
sizes[*x11_strut::TOP_START_X] = std::clamp(window.x, 0, display_width);
sizes[*x11_strut::TOP_END_X] =
std::clamp(window.x + window.width + 6, 0, display_width);
break;
case axis_align::END:
sizes[*x11_strut::BOTTOM] =
std::clamp(display_height - window.y, 0, display_height);
sizes[*x11_strut::BOTTOM_START_X] =
std::clamp(window.x, 0, display_width);
sizes[*x11_strut::BOTTOM_END_X] =
std::clamp(window.x + window.width, 0, display_width);
break;
case axis_align::MIDDLE:
// can't reserve space in middle of the screen
default:
break;
}
switch (horizontal_alignment(align)) {
case axis_align::START:
sizes[*x11_strut::LEFT] =
Expand All @@ -1157,7 +1135,28 @@ void set_struts(alignment align) {
std::clamp(window.y + window.height, 0, display_height);
break;
case axis_align::MIDDLE:
// can't reserve space in middle of the screen
switch (vertical_alignment(align)) {
case axis_align::START:
sizes[*x11_strut::TOP] =
std::clamp(window.y + window.height, 0, display_height);
sizes[*x11_strut::TOP_START_X] =
std::clamp(window.x, 0, display_width);
sizes[*x11_strut::TOP_END_X] =
std::clamp(window.x + window.width + 6, 0, display_width);
break;
case axis_align::END:
sizes[*x11_strut::BOTTOM] =
std::clamp(display_height - window.y, 0, display_height);
sizes[*x11_strut::BOTTOM_START_X] =
std::clamp(window.x, 0, display_width);
sizes[*x11_strut::BOTTOM_END_X] =
std::clamp(window.x + window.width, 0, display_width);
break;
case axis_align::MIDDLE:
// can't reserve space in middle of the screen
default:
break;
}
default:
break;
}
Expand Down

0 comments on commit cb6adb7

Please sign in to comment.