From 8779a3e645f4ccd5de668c8f41370f40938a6e5a Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 7 Apr 2023 18:49:21 +0300 Subject: [PATCH 25/25] Fix clipping in update_map_canvas() On gtk-clients bad clipping eventually showed up as a warning from pixman. Reported by jdlh See osdn #42262 Signed-off-by: Marko Lindqvist --- client/mapview_common.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/client/mapview_common.c b/client/mapview_common.c index bed85a997a..29ab185e60 100644 --- a/client/mapview_common.c +++ b/client/mapview_common.c @@ -1701,10 +1701,26 @@ void update_map_canvas(int canvas_x, int canvas_y, int width, int height) bool full; struct canvas *tmp; - canvas_x = MAX(canvas_x, 0); - canvas_y = MAX(canvas_y, 0); - width = MIN(mapview.store_width - canvas_x, width); - height = MIN(mapview.store_height - canvas_y, height); + if (canvas_x < 0) { + width += canvas_x; + canvas_x = 0; + } else if (canvas_x > mapview.store_width) { + width -= (canvas_x - mapview.store_width); + canvas_x = mapview.store_width; + } + + if (canvas_y < 0) { + height += canvas_y; + canvas_y = 0; + } else if (canvas_y > mapview.store_height) { + height -= (canvas_y - mapview.store_height); + canvas_y = mapview.store_height; + } + + if (width <= 0 || height <= 0) { + /* Area outside mapview */ + return; + } gui_x0 = mapview.gui_x0 + canvas_x; gui_y0 = mapview.gui_y0 + canvas_y; -- 2.39.2