Changeset c632c96 in mainline


Ignore:
Timestamp:
2021-10-25T00:32:45Z (3 years ago)
Author:
jxsvoboda <5887334+jxsvoboda@…>
Branches:
master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
39ab17c
Parents:
f59212cc
git-author:
Jiri Svoboda <jiri@…> (2021-10-20 22:22:04)
git-committer:
jxsvoboda <5887334+jxsvoboda@…> (2021-10-25 00:32:45)
Message:

Unmap and clear console before executing a binary

Fixes running edit, nav, improves fdisk, etc.

Location:
uspace
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/nav/panel.c

    rf59212cc rc632c96  
    10791079        int retval;
    10801080        errno_t rc;
     1081        ui_t *ui;
    10811082
    10821083        /* It's not a directory */
     
    10851086        assert(entry->svc == 0);
    10861087
     1088        ui = ui_window_get_ui(panel->window);
     1089
     1090        /* Free up and clean console for the child task. */
     1091        rc = ui_suspend(ui);
     1092        if (rc != EOK)
     1093                return rc;
     1094
    10871095        rc = task_spawnl(&id, &wait, entry->name, entry->name, NULL);
    10881096        if (rc != EOK)
    1089                 return rc;
     1097                goto error;
    10901098
    10911099        rc = task_wait(&wait, &texit, &retval);
    10921100        if ((rc != EOK) || (texit != TASK_EXIT_NORMAL))
     1101                goto error;
     1102
     1103        /* Resume UI operation */
     1104        rc = ui_resume(ui);
     1105        if (rc != EOK)
    10931106                return rc;
    10941107
    10951108        (void) ui_paint(ui_window_get_ui(panel->window));
    10961109        return EOK;
     1110error:
     1111        (void) ui_resume(ui);
     1112        (void) ui_paint(ui_window_get_ui(panel->window));
     1113        return rc;
    10971114}
    10981115
  • uspace/lib/congfx/include/congfx/console.h

    rf59212cc rc632c96  
    4747extern errno_t console_gc_create(console_ctrl_t *, FILE *, console_gc_t **);
    4848extern errno_t console_gc_delete(console_gc_t *);
     49extern errno_t console_gc_suspend(console_gc_t *);
     50extern errno_t console_gc_resume(console_gc_t *);
    4951extern gfx_context_t *console_gc_get_ctx(console_gc_t *);
    5052
  • uspace/lib/congfx/src/console.c

    rf59212cc rc632c96  
    281281}
    282282
     283/** Free up console for other users, suspending GC operation.
     284 *
     285 * @param cgc Console GC
     286 * @return EOK on success or an error code
     287 */
     288errno_t console_gc_suspend(console_gc_t *cgc)
     289{
     290        console_unmap(cgc->con, cgc->buf);
     291        cgc->buf = NULL;
     292
     293        console_clear(cgc->con);
     294        console_cursor_visibility(cgc->con, true);
     295        return EOK;
     296}
     297
     298/** Resume GC operation after suspend.
     299 *
     300 * @param cgc Console GC
     301 * @return EOK on success or an error code
     302 */
     303errno_t console_gc_resume(console_gc_t *cgc)
     304{
     305        errno_t rc;
     306
     307        console_clear(cgc->con);
     308
     309        rc = console_map(cgc->con, cgc->rect.p1.x, cgc->rect.p1.y, &cgc->buf);
     310        if (rc != EOK)
     311                return rc;
     312
     313        return EOK;
     314}
     315
    283316/** Get generic graphic context from console GC.
    284317 *
  • uspace/lib/ui/include/ui/ui.h

    rf59212cc rc632c96  
    5252extern bool ui_is_textmode(ui_t *);
    5353extern bool ui_is_fullscreen(ui_t *);
     54extern errno_t ui_suspend(ui_t *);
     55extern errno_t ui_resume(ui_t *);
    5456
    5557#endif
  • uspace/lib/ui/src/ui.c

    rf59212cc rc632c96  
    4040#include <fibril.h>
    4141#include <gfx/color.h>
     42#include <gfx/cursor.h>
    4243#include <gfx/render.h>
    4344#include <io/console.h>
     
    355356}
    356357
     358/** Free up console for other users.
     359 *
     360 * Release console resources for another application (that the current
     361 * task is starting). After the other application finishes, resume
     362 * operation with ui_resume(). No calls to UI must happen inbetween
     363 * and no events must be processed (i.e. the calling function must not
     364 * return control to UI.
     365 *
     366 * @param ui UI
     367 * @return EOK on success or an error code
     368 */
     369errno_t ui_suspend(ui_t *ui)
     370{
     371        if (ui->cgc == NULL)
     372                return EOK;
     373
     374        return console_gc_suspend(ui->cgc);
     375}
     376
     377/** Resume suspended UI.
     378 *
     379 * Reclaim console resources (after child application has finished running)
     380 * and restore UI operation previously suspended by calling ui_suspend().
     381 *
     382 * @param ui UI
     383 * @return EOK on success or an error code
     384 */
     385errno_t ui_resume(ui_t *ui)
     386{
     387        errno_t rc;
     388
     389        if (ui->cgc == NULL)
     390                return EOK;
     391
     392        rc = console_gc_resume(ui->cgc);
     393        if (rc != EOK)
     394                return rc;
     395
     396        return gfx_cursor_set_visible(console_gc_get_ctx(ui->cgc), false);
     397}
     398
    357399/** Terminate user interface.
    358400 *
  • uspace/lib/ui/test/ui.c

    rf59212cc rc632c96  
    6767{
    6868        ui_destroy(NULL);
     69}
     70
     71/** ui_suspend() / ui_resume() do nothing if we don't have a console */
     72PCUT_TEST(suspend_resume)
     73{
     74        ui_t *ui = NULL;
     75        errno_t rc;
     76
     77        rc = ui_create_disp(NULL, &ui);
     78        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     79        PCUT_ASSERT_NOT_NULL(ui);
     80
     81        rc = ui_suspend(ui);
     82        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     83        rc = ui_resume(ui);
     84        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     85
     86        ui_destroy(ui);
    6987}
    7088
Note: See TracChangeset for help on using the changeset viewer.