Skip to content

Commit

Permalink
fixup! fix(ui): the widgets created in the ready event handler aren't…
Browse files Browse the repository at this point in the history
… updated
  • Loading branch information
lc-soft committed May 6, 2024
1 parent e77d6bc commit aa42591
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
1 change: 1 addition & 0 deletions lib/ui-router/tests/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ void test_router_components(void)

ui_event_init(&e, "click");
ui_widget_emit_event(link_foo, e, NULL);
// ui_update();
matched_widget = ui_router_view_get_matched_widget(view);
ctest_equal_bool("[/foo] <router-view> widget should load <foo> widget",
strcmp(matched_widget->type, "foo") == 0, TRUE);
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/include/ui/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ LIBUI_PUBLIC size_t ui_widget_render(ui_widget_t *w, pd_context_t *paint);
// Updater

LIBUI_PUBLIC size_t ui_widget_update(ui_widget_t *w);
LIBUI_PUBLIC size_t ui_update(void);
LIBUI_PUBLIC void ui_update(void);

LIBUI_PUBLIC void ui_refresh_style(void);

LIBUI_PUBLIC void ui_widget_set_rules(ui_widget_t *w,
Expand Down
17 changes: 9 additions & 8 deletions lib/ui/src/ui_updater.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <ui/metrics.h>
#include <ui/mutation_observer.h>
#include <ui/hash.h>
#include <ui/image.h>
#include "ui_debug.h"
#include "ui_diff.h"
#include "ui_updater.h"
Expand Down Expand Up @@ -98,7 +99,7 @@ void ui_widget_set_rules(ui_widget_t* w, const ui_widget_rules_t* rules)
w->extra->default_max_update_count = 2048;
}

void ui_widget_update_stacking_context(ui_widget_t* w)
static void ui_widget_update_stacking_context(ui_widget_t* w)
{
ui_widget_t *child, *target;
css_computed_style_t *s, *ts;
Expand Down Expand Up @@ -469,22 +470,22 @@ static void ui_process_mutations(ui_widget_t* w)
w->update.border_box_backup = w->border_box;
}

size_t ui_update(void)
void ui_update(void)
{
size_t count;
ui_widget_t* root;

root = ui_root();
ui_widget_t *root = ui_root();
if (memcmp(&ui_metrics, &ui_updater.metrics, sizeof(ui_metrics_t))) {
ui_updater.refresh_all = true;
root->rendering.dirty_rect_type = UI_DIRTY_RECT_TYPE_FULL;
}
count = ui_widget_update(root);
ui_process_image_events();
ui_process_events();
ui_widget_update(root);
ui_updater.metrics = ui_metrics;
ui_updater.refresh_all = false;
ui_process_mutations(root);
ui_process_mutation_observers();
return count;
ui_process_events();
ui_clear_trash();
}

void ui_init_updater(void)
Expand Down
4 changes: 0 additions & 4 deletions src/lcui_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,7 @@ size_t lcui_render_ui(void)

void lcui_update_ui(void)
{
ui_clear_trash();
ui_process_image_events();
ui_process_events();
ui_update();

thread_mutex_lock(&lcui_ui.image_loader.mutex);
ui_clear_images();
thread_mutex_unlock(&lcui_ui.image_loader.mutex);
Expand Down

0 comments on commit aa42591

Please sign in to comment.