From 2f2ee8753ae1ded63676b049f1043dc822fe057c Mon Sep 17 00:00:00 2001 From: Wei-Hsin Yeh Date: Mon, 20 Jan 2025 00:20:48 +0800 Subject: [PATCH 1/2] Fix widgets not updating with parent's widget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implement the twin_widget_children_paint function to repaint all the box's widgets. The issue arises when the spline updates the pixmap beneath the button widget, the pixmap of the button isn't triggered to repaint. To solve this, we call the twin_widget_paint function after the spline update to ensure the related widget will be repainted. Signed-off-by: Wei-Hsin Yeh --- apps/spline.c | 1 + include/twin.h | 3 +++ src/widget.c | 7 +++++++ 3 files changed, 11 insertions(+) diff --git a/apps/spline.c b/apps/spline.c index 5990c3e..fff24ff 100644 --- a/apps/spline.c +++ b/apps/spline.c @@ -129,6 +129,7 @@ static twin_dispatch_result_t _apps_spline_update_pos(apps_spline_t *spline, spline->points[spline->which].y = twin_sfixed_to_fixed( _twin_matrix_y(&(spline->inverse_transition), x, y)); _twin_widget_queue_paint(&spline->widget); + twin_widget_children_paint((spline->widget).parent); return TwinDispatchDone; } diff --git a/include/twin.h b/include/twin.h index b9b9527..834e57a 100644 --- a/include/twin.h +++ b/include/twin.h @@ -1124,6 +1124,9 @@ twin_angle_t twin_acos(twin_fixed_t x); * widget.c */ +/* Paint the widget children of the box. */ +void twin_widget_children_paint(twin_box_t *box); + twin_widget_t *twin_widget_create(twin_box_t *parent, twin_argb32_t background, twin_coord_t width, diff --git a/src/widget.c b/src/widget.c index 2855e58..b694f10 100644 --- a/src/widget.c +++ b/src/widget.c @@ -200,6 +200,13 @@ void _twin_widget_bevel(twin_widget_t *widget, twin_fixed_t b, bool down) } } +void twin_widget_children_paint(twin_box_t *box) +{ + /* Paint the widget children of the box. */ + for (twin_widget_t *child = box->children; child; child = child->next) + _twin_widget_queue_paint(child); +} + twin_widget_t *twin_widget_create(twin_box_t *parent, twin_argb32_t background, twin_coord_t width, From 56bc784f6161c3a35aba987d7a0ee5ba0f7969ed Mon Sep 17 00:00:00 2001 From: Wei-Hsin Yeh Date: Tue, 21 Jan 2025 00:25:21 +0800 Subject: [PATCH 2/2] Fix global redisplay not matching window updates The global redisplay thread would block on a semaphore, which is signaled by the per-window redisplay threads whenever the content of any window changes. For example, the per-window redisplay thread is triggered when its content twin_box_t is triggered by the event TwinEventButtonDown. In this case, the corresponding window should also be marked as active. To ensure proper display, we added the function twin_window_show to indirectly update the damaged screen. Signed-off-by: Wei-Hsin Yeh --- src/box.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/box.c b/src/box.c index f85138d..71945ae 100644 --- a/src/box.c +++ b/src/box.c @@ -163,6 +163,7 @@ twin_dispatch_result_t _twin_box_dispatch(twin_widget_t *widget, case TwinEventConfigure: return _twin_box_configure(box); case TwinEventButtonDown: + twin_window_show(widget->window); box->button_down = _twin_box_xy_to_widget(box, event->u.pointer.x, event->u.pointer.y); if (box->button_down && box->button_down->want_focus)