Changeset e3e64f6 in mainline


Ignore:
Timestamp:
2021-11-04T16:36:15Z (2 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f0155e4
Parents:
bad765a
Message:

Pause before resuming UI, if needed

To be able to see output of commands executed from Navigator, we need
to pause before repainting the UI. This should not be needed, however,
for binaries that do not leave anything on the screen (e.g. (G)UI
applications). We use a simple heuristic - if the cursor is in the top
left corner of the screen, we don't pause.

File:
1 edited

Legend:

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

    rbad765a re3e64f6  
    399399        errno_t rc;
    400400        ui_window_t *awnd;
     401        sysarg_t col;
     402        sysarg_t row;
     403        cons_event_t ev;
    401404
    402405        if (ui->cgc == NULL)
    403406                return EOK;
     407
     408        rc = console_get_pos(ui->console, &col, &row);
     409        if (rc != EOK)
     410                return rc;
     411
     412        /*
     413         * Here's a little heuristic to help determine if we need
     414         * to pause before returning to the UI. If we are in the
     415         * top-left corner, chances are the screen is empty and
     416         * there is no need to pause.
     417         */
     418        if (col != 0 || row != 0) {
     419                printf("Press any key or button to continue...\n");
     420
     421                while (true) {
     422                        rc = console_get_event(ui->console, &ev);
     423                        if (rc != EOK)
     424                                return EIO;
     425
     426                        if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS)
     427                                break;
     428
     429                        if (ev.type == CEV_POS && ev.ev.pos.type == POS_PRESS)
     430                                break;
     431                }
     432        }
    404433
    405434        rc = console_gc_resume(ui->cgc);
Note: See TracChangeset for help on using the changeset viewer.