Changeset 77ffa01 in mainline for uspace/lib/ui/src/window.c


Ignore:
Timestamp:
2021-02-27T21:34:15Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9c7dc8e
Parents:
b433f68
Message:

Allow UI to run in the console

Note that everything is way too large.

File:
1 edited

Legend:

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

    rb433f68 r77ffa01  
    3434 */
    3535
     36#include <congfx/console.h>
    3637#include <display.h>
    3738#include <errno.h>
     
    130131        gfx_bitmap_t *bmp = NULL;
    131132        mem_gc_t *memgc = NULL;
     133        console_gc_t *cgc;
    132134        errno_t rc;
     135
     136        if (ui->root_wnd != NULL)
     137                return EEXIST;
    133138
    134139        window = calloc(1, sizeof(ui_window_t));
     
    194199                if (rc != EOK)
    195200                        goto error;
     201        } else if (ui->console != NULL) {
     202                rc = console_gc_create(ui->console, NULL, &cgc);
     203                if (rc != EOK)
     204                        goto error;
     205
     206                gc = console_gc_get_ctx(cgc);
    196207        } else {
    197208                /* Needed for unit tests */
     
    207218        gfx_bitmap_params_init(&bparams);
    208219#ifndef CONFIG_WIN_DOUBLE_BUF
    209         bparams.flags |= bmpf_direct_output;
     220        /* Console does not support direct output */
     221        if (ui->display != NULL)
     222                bparams.flags |= bmpf_direct_output;
    210223#endif
    211224
     
    262275        window->cursor = ui_curs_arrow;
    263276        *rwindow = window;
     277
     278        ui->root_wnd = window;
    264279        return EOK;
    265280error:
     
    303318                gfx_bitmap_destroy(window->bmp);
    304319        gfx_context_delete(window->gc);
    305         display_window_destroy(window->dwindow);
     320        if (window->dwindow != NULL)
     321                display_window_destroy(window->dwindow);
    306322        free(window);
    307323}
     
    650666        ui_window_t *window = (ui_window_t *) arg;
    651667
    652         (void) display_window_move_req(window->dwindow, pos);
     668        if (window->dwindow != NULL)
     669                (void) display_window_move_req(window->dwindow, pos);
    653670}
    654671
     
    665682        ui_window_t *window = (ui_window_t *) arg;
    666683
    667         (void) display_window_resize_req(window->dwindow, rsztype, pos);
     684        if (window->dwindow != NULL)
     685                (void) display_window_resize_req(window->dwindow, rsztype, pos);
    668686}
    669687
     
    703721        }
    704722
    705         (void) display_window_set_cursor(window->dwindow, dcursor);
     723        if (window->dwindow != NULL)
     724                (void) display_window_set_cursor(window->dwindow, dcursor);
    706725        window->cursor = cursor;
    707726}
Note: See TracChangeset for help on using the changeset viewer.