diff options
| author | Sunderland93 <[email protected]> | 2026-08-10 12:28:17 +0400 |
|---|---|---|
| committer | Luke from DC <[email protected]> | 2026-08-19 20:14:33 +0000 |
| commit | 433a202b39187160bb2ee5a43cfaba66d3b4a7a4 (patch) | |
| tree | d5ba6d0d8fb5fc943af5d1df47995ccd0caffb8b /capplets | |
| parent | 7db3f6732cd46160b254007843aafc728f00ee63 (diff) | |
| download | mate-control-center-433a202b39187160bb2ee5a43cfaba66d3b4a7a4.tar.bz2 mate-control-center-433a202b39187160bb2ee5a43cfaba66d3b4a7a4.tar.xz | |
Fix the unit mismatch in Wayland display capplet
Diffstat (limited to 'capplets')
| -rw-r--r-- | capplets/display/wlrandr-capplet.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/capplets/display/wlrandr-capplet.c b/capplets/display/wlrandr-capplet.c index 980892cc..bd7f9d8f 100644 --- a/capplets/display/wlrandr-capplet.c +++ b/capplets/display/wlrandr-capplet.c @@ -268,6 +268,24 @@ get_geometry (OutputHead *head, int *w, int *h) } } +/* Head sizes are reported in physical pixels while head positions are + * given in logical pixels (see HEAD_INFO_FIELD_X). The preview must + * divide the physical size by the output's scale to stay in the same + * coordinate space as the positions; otherwise the arrangement is drawn + * off-center and clipped on scaled outputs. + */ +static void +get_geometry_scaled (OutputHead *head, int *w, int *h) +{ + get_geometry (head, w, h); + + if (head->scale > 0.0) + { + *w = (int) ((double) *w / head->scale + 0.5); + *h = (int) ((double) *h / head->scale + 0.5); + } +} + static int count_active_outputs (App *app) { @@ -305,7 +323,7 @@ list_heads (App *app, int *total_w, int *total_h) result = g_list_prepend (result, head); - get_geometry (head, &w, &h); + get_geometry_scaled (head, &w, &h); *total_w += w; *total_h += h; @@ -1491,7 +1509,7 @@ list_edges_for_output (OutputHead *head, GArray *edges) x = head->x; y = head->y; - get_geometry (head, &w, &h); + get_geometry_scaled (head, &w, &h); /* Top, Bottom, Left, Right */ add_edge (head, x, y, x + w, y, edges); @@ -1890,7 +1908,7 @@ paint_head (App *app, foo_scroll_area_get_viewport (FOO_SCROLL_AREA (app->area), &viewport); - get_geometry (head, &w, &h); + get_geometry_scaled (head, &w, &h); viewport.height -= 2 * MARGIN; viewport.width -= 2 * MARGIN; |
