1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-20 04:48:06 +01:00

Correct calculation of usable space for reserved area.

Previous patch has correct the way, how reserved area found in
_NET_WM_STRUT was calculated. Unfortunately, the calculation was not
precise, as for not reserved areas (i.e. values of 0 for one of the
cardinals is set) must be calculated anyway for given head, otherwise
usable area might be too broad.
This commit is contained in:
2021-03-18 16:41:36 +01:00
committed by Carlos R. Mafra
parent bbf24d1d39
commit 82ab2d2d06

View File

@@ -845,43 +845,56 @@ Bool wNETWMGetUsableArea(WScreen *scr, int head, WArea *area)
rect = wGetRectForHead(scr, head); rect = wGetRectForHead(scr, head);
/* NOTE(gryf): calculation for the reserved area should be preformed for /* NOTE(gryf): calculation for the reserved area should be preformed for
* current head, but area, which comes form _NET_WM_STRUT, has to be * current head, but area, which comes form _NET_WM_STRUT, has to be
* calculated relative to entire screen size, i.e. suppose we have three * calculated relative to entire screen size, i.e. suppose we have three
* heads arranged like this: * heads arranged like this:
* *
* ╔════════════════════════╗ * ╔════════════════════════╗
* ║ 0 ║ * ║ 0 ║
* ║ ╠═══════════╗ * ║ ╠═══════════╗
* ║ ║ 2 ║ * ║ ║ 2 ║
* ║ ║ ║ * ║ ║ ║
* ╟────────────────────────╫───────────╢ * ╟────────────────────────╫───────────╢
* ╠════════════════════════╬═══════════╝ * ╠════════════════════════╬═══════════╝
* ║ 1 ║ * ║ 1 ║
* ║ ║ * ║ ║
* ║ ║ * ║ ║
* ║ ║ * ║ ║
* ║ ║ * ║ ║
* ╟────────────────────────╢ * ╟────────────────────────╢
* ╚════════════════════════╝ * ╚════════════════════════╝
* *
* where head 0 have resolution 1920x1080, head 1: 1920x1200 and head 2 * where head 0 have resolution 1920x1080, head 1: 1920x1200 and head 2
* 800x600, so the screen size in this arrangement will be 2720x2280 (1920 * 800x600, so the screen size in this arrangement will be 2720x2280 (1920
* + 800) x (1080 + 1200). * + 800) x (1080 + 1200).
* *
* Bottom line represents some 3rd party panel, which sets properties in * Bottom line represents some 3rd party panel, which sets properties in
* _NET_WM_STRUT_PARTIAL and optionally _NET_WM_STRUT. * _NET_WM_STRUT_PARTIAL and optionally _NET_WM_STRUT.
* *
* By coincidence, coordinates x1 and y1 from left and top are the same as * By coincidence, coordinates x1 and y1 from left and top are the same as
* the original data which came from _NET_WM_STRUT, since they meaning * the original data which came from _NET_WM_STRUT, since they meaning
* distance from the edge. * distance from the edge, so we leave it as-is, otherwise if they have 0
*/ * value, we need to set right head position.
*/
/* optional reserved space from right */ /* optional reserved space from left */
area->x2 = scr->scr_width - area->x2; if (area->x1 == 0) area->x1 = rect.pos.x;
/* optional reserved space from bottom */ /* optional reserved space from top */
area->y2 = scr->scr_height - area->y2; if (area->y1 == 0) area->y1 = rect.pos.y;
/* optional reserved space from right */
if (area->x2 == 0)
area->x2 = rect.pos.x + rect.size.width;
else
area->x2 = scr->scr_width - area->x2;
/* optional reserved space from bottom */
if (area->y2 == 0)
area->y2 = rect.pos.y + rect.size.height;
else
area->y2 = scr->scr_height - area->y2;
return True; return True;
} }