From f64bfeb7fd5171755df1f5f052936f7ef1603185 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Thu, 29 May 2025 21:09:24 +0100 Subject: [PATCH] invalidate map only when app-state changes --- pkgs/maps/main.fnl | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pkgs/maps/main.fnl b/pkgs/maps/main.fnl index dadd191..e349eab 100644 --- a/pkgs/maps/main.fnl +++ b/pkgs/maps/main.fnl @@ -76,11 +76,9 @@ label.readout { ;; to fill the width of the screen plus a bit (fn cairo-the-map [self g] - (: (self:get_window) :invalidate_rect nil) (let [{ : lat : lon : zoom } app-state num-tiles-x (+ 0 (math.ceil (/ map-width tile-size))) num-tiles-y (+ 0 (math.ceil (/ map-height tile-size))) - ; _ (print app-state.lat app-state.lon) (tile-x tile-y) (tiles.latlon->tile app-state.lat app-state.lon app-state.zoom) min-tile-x (math.floor (- tile-x (/ num-tiles-x 2))) max-tile-x (math.ceil (+ tile-x (/ num-tiles-x 2))) @@ -115,12 +113,17 @@ label.readout { (g:stroke) true)) +(fn register-widget [name widget] + (tset state-widgets name widget) + widget) (fn osm-widget [] - (Gtk.DrawingArea { - :width map-width :height map-height - :on_draw cairo-the-map - })) + (register-widget + :osm + (Gtk.DrawingArea { + :width map-width :height map-height + :on_draw cairo-the-map + }))) (fn readout [name text] (let [w @@ -153,7 +156,7 @@ label.readout { (case name :speed (widget:set_label (string.format "%.1f km/h" (* app-state.speed 3.6))) - :osm (widget:set_center app-state.lat app-state.lon) + :osm (: (widget:get_window) :invalidate_rect nil) :time (widget:set_label (hhmmss (+ utc-offset app-state.time-of-day))) )))