[FIX/WIP] Try to fix concurrency issue

I still don't know why the timer conflicts with netting code. It has
absolutely no reason to do that, since it's only job is rendering a
singular jmlist.
This commit is contained in:
lda 2024-04-05 07:59:01 +02:00
parent de27dddf3e
commit c54e5cf881
3 changed files with 28 additions and 19 deletions

View File

@ -379,13 +379,22 @@ static void show_msg(m_room_t *r, m_user_t *u, m_event_t *e, jwidget *w)
{
json_value_t *url_val;
jmimage *img;
jwidget *img_holder;
jwidget *blank;
url_val = utils_hashmap_get(e->content, "url");
img_holder = jwidget_create(w);
jlayout_set_hbox(img_holder)->spacing = 0;
img = matrix_image_from_mxc(
w, u,
utils_json_as_string(url_val), 96
img_holder,
u,
utils_json_as_string(url_val),
96
);
jwidget_set_stretch(img, 1, 0, false);
blank = jwidget_create(img_holder);
jwidget_set_stretch(blank, 1, 0, false);
jwidget_set_stretch(img_holder, 1, 0, false);
jwidget_set_stretch(w, 1, 0, false);
return;
}
if (!strcmp(subtype, "m.file"))

View File

@ -139,10 +139,9 @@ bool ui_manage_event(ui_session_t *ui, jevent e)
widget = screen->on_event(screen, e);
if (widget)
{
/* TODO: Actually investigate on this arsehole */
/*log_text("focusing (%p, %p)", ui->justui_screen, widget);*/
/* TODO: Actually investigate on this arsehole with better
* tools. Right now, it's pretty much a mystery */
jscene_set_focused_widget(ui->justui_screen, widget);
/*log_text("focused");*/
return true;
}
return false;
@ -172,12 +171,6 @@ int loop_cb(ui_session_t *ui)
dupdate();
goto end;
}
if (ui_manage_event(ui, e))
{
dclear(C_WHITE);
jscene_render(ui->justui_screen);
dupdate();
}
end:
flag = false;
return TIMER_CONTINUE;
@ -187,7 +180,7 @@ void ui_session_loop(ui_session_t *ui)
int key = 0;
ui->backTimer = timer_configure(
TIMER_ANY,
FPS(120),
FPS(20),
GINT_CALL(loop_cb, (volatile void *) ui)
);
jevent e;

View File

@ -207,7 +207,7 @@ void * ui_room_init(ui_screen_t *that)
extra->timer_id = timer_configure(
TIMER_ANY,
3 * 1000000,
750000,
GINT_CALL(timer_cb, (void *) that)
);
@ -600,6 +600,10 @@ static void manage_command(ui_screen_t *that, command_t *cmd)
void * ui_room_event(ui_screen_t *that, jevent e)
{
ui_room_extra_t *extra = that->data;
if (that->owner->waiting)
{
return NULL;
}
if (extra->time_head)
{
if (e.key.key == KEY_EXIT && e.key.type == KEYEV_UP)
@ -628,7 +632,7 @@ void * ui_room_event(ui_screen_t *that, jevent e)
}
if (e.type == JMLIST_ITEM_OVERFLEW && !extra->file)
{
if (jmlist_selected(extra->timeline) != 0)
if (jmlist_selected(extra->timeline) != 0 || that->owner->waiting)
{
return NULL;
}
@ -636,7 +640,7 @@ void * ui_room_event(ui_screen_t *that, jevent e)
extra->timeline->widget.update = 1;
return extra->timeline;
}
if (e.type == JMLIST_ITEM_NOP && !extra->file)
if (e.type == JMLIST_ITEM_NOP && !extra->file && !that->owner->waiting)
{
ui_room_extra_t *extra = that->data;
m_event_t *e;
@ -647,9 +651,11 @@ void * ui_room_event(ui_screen_t *that, jevent e)
e = utils_array_get(extra->room->timeline, 0);
if (that->owner->waiting) return NULL;
ui_set_business(that->owner, true);
log_text("doing mah work");
matrix_update_room_history(extra->user, extra->room, e, 10);
log_text("done mah work");
ui_set_business(that->owner, false);
from = is_in_timeline(extra->room, e->event_id);
if (from != 0)
@ -693,7 +699,6 @@ void * ui_room_event(ui_screen_t *that, jevent e)
}
}
ui_set_business(that->owner, false);
extra->input->mode = code; /* It seems like the input doesn't keep
its mode, somehow??????? */
((ui_room_extra_t *) that->data)->flag1 = false;
@ -717,6 +722,7 @@ void * ui_room_event(ui_screen_t *that, jevent e)
{
m_event_t *event;
const char *input = jinput_value(extra->input);
if (that->owner->waiting) return NULL;
if (strlen(input) > 0 && *input == '/')
{
command_t *cmd = command_parse((char *)input);
@ -729,13 +735,14 @@ void * ui_room_event(ui_screen_t *that, jevent e)
return extra->timeline;
}
event = send_msg(extra);
if (that->owner->waiting) return NULL;
ui_set_business(that->owner, true);
matrix_update_room_history(extra->user, extra->room, event, 5);
ui_set_business(that->owner, false);
return extra->timeline;
}
if (that->owner->waiting) return NULL;
/* Need to find a better keycomb */
if (e.key.key == KEY_DIV && e.key.type == KEYEV_UP && !extra->file)
{