How to control the shape of the invalidation area

I want to limit the shape of the invalid area, for example, always being the screen width * specified number of lines.

You can implement a custom rounder callback and attach it to your display using the LV_EVENT_INVALIDATE_AREA event. This allows you to control how redraw regions are adjusted before rendering.

https://docs.lvgl.io/master/main-modules/display/redraw_area.html