Changeset 983052c in mainline for uspace/lib/ui/src/ui.c


Ignore:
Timestamp:
2023-10-10T12:30:54Z (15 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bd2fab5
Parents:
9bec33a
git-author:
Jiri Svoboda <jiri@…> (2023-10-09 18:30:06)
git-committer:
Jiri Svoboda <jiri@…> (2023-10-10 12:30:54)
Message:

Task bar should not crash when starting in terminal

Firstly, we need to make sure we do not paint anything while
UI is suspended. Also, we were missing calls to ui_lock/unlock()
while delivering kbd/pos events from console.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/src/ui.c

    r9bec33a r983052c  
    338338        switch (event->type) {
    339339        case CEV_KEY:
     340                ui_lock(ui);
    340341                ui_window_send_kbd(awnd, &event->ev.key);
     342                ui_unlock(ui);
    341343                break;
    342344        case CEV_POS:
     
    348350                claim = ui_wdecor_pos_event(awnd->wdecor, &pos);
    349351                /* Note: If event is claimed, awnd might not be valid anymore */
    350                 if (claim == ui_unclaimed)
     352                if (claim == ui_unclaimed) {
     353                        ui_lock(ui);
    351354                        ui_window_send_pos(awnd, &pos);
     355                        ui_unlock(ui);
     356                }
    352357
    353358                break;
     
    454459errno_t ui_suspend(ui_t *ui)
    455460{
    456         if (ui->cgc == NULL)
     461        errno_t rc;
     462
     463        assert(!ui->suspended);
     464
     465        if (ui->cgc == NULL) {
     466                ui->suspended = true;
    457467                return EOK;
     468        }
    458469
    459470        (void) console_set_caption(ui->console, "");
    460         return console_gc_suspend(ui->cgc);
     471        rc = console_gc_suspend(ui->cgc);
     472        if (rc != EOK)
     473                return rc;
     474
     475        ui->suspended = true;
     476        return EOK;
    461477}
    462478
     
    477493        cons_event_t ev;
    478494
    479         if (ui->cgc == NULL)
     495        assert(ui->suspended);
     496
     497        if (ui->cgc == NULL) {
     498                ui->suspended = false;
    480499                return EOK;
     500        }
    481501
    482502        rc = console_get_pos(ui->console, &col, &row);
     
    510530                return rc;
    511531
     532        ui->suspended = false;
     533
    512534        awnd = ui_window_get_active(ui);
    513535        if (awnd != NULL)
    514536                (void) console_set_caption(ui->console, awnd->wdecor->caption);
    515537
    516         return gfx_cursor_set_visible(console_gc_get_ctx(ui->cgc), false);
     538        rc = gfx_cursor_set_visible(console_gc_get_ctx(ui->cgc), false);
     539        if (rc != EOK)
     540                return rc;
     541
     542        return EOK;
     543}
     544
     545/** Determine if UI is suspended.
     546 *
     547 * @param ui UI
     548 * @return @c true iff UI is suspended
     549 */
     550bool ui_is_suspended(ui_t *ui)
     551{
     552        return ui->suspended;
    517553}
    518554
Note: See TracChangeset for help on using the changeset viewer.