Changeset 252d03c in mainline for uspace/lib/ui/src/window.c


Ignore:
Timestamp:
2021-04-28T09:22:39Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7470d97
Parents:
de227aba
Message:

Popping up a message, in text mode as well

File:
1 edited

Legend:

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

    rde227aba r252d03c  
    133133        gfx_bitmap_t *bmp = NULL;
    134134        mem_gc_t *memgc = NULL;
    135         console_gc_t *cgc = NULL;
    136135        errno_t rc;
    137 
    138         if (ui->root_wnd != NULL)
    139                 return EEXIST;
    140136
    141137        window = calloc(1, sizeof(ui_window_t));
     
    202198                        goto error;
    203199        } else if (ui->console != NULL) {
    204                 rc = console_gc_create(ui->console, NULL, &cgc);
    205                 if (rc != EOK)
    206                         goto error;
    207 
    208                 gc = console_gc_get_ctx(cgc);
     200                gc = console_gc_get_ctx(ui->cgc);
    209201        } else {
    210202                /* Needed for unit tests */
     
    257249        window->gc = gc;
    258250#endif
    259         window->cgc = cgc;
    260251
    261252        rc = ui_resource_create(window->gc, ui_is_textmode(ui), &res);
     
    282273        *rwindow = window;
    283274
    284         ui->root_wnd = window;
     275        list_append(&window->lwindows, &ui->windows);
    285276        return EOK;
    286277error:
     
    295286        if (dgc != NULL)
    296287                dummygc_destroy(dgc);
    297         if (cgc != NULL)
    298                 console_gc_delete(cgc);
    299288        if (dwindow != NULL)
    300289                display_window_destroy(dwindow);
     
    309298void ui_window_destroy(ui_window_t *window)
    310299{
     300        ui_t *ui;
     301
    311302        if (window == NULL)
    312303                return;
    313304
     305        ui = window->ui;
     306
     307        list_remove(&window->lwindows);
    314308        ui_control_destroy(window->control);
    315309        ui_wdecor_destroy(window->wdecor);
     
    328322        if (window->dwindow != NULL)
    329323                display_window_destroy(window->dwindow);
    330         if (window->cgc != NULL)
    331                 console_gc_delete(window->cgc);
     324
    332325        free(window);
     326
     327        /* Need to repaint if windows are emulated */
     328        if (ui_is_fullscreen(ui)) {
     329                ui_paint(ui);
     330        }
    333331}
    334332
     
    362360        window->control = NULL;
    363361        control->elemp = NULL;
     362}
     363
     364/** Get active window (only valid in fullscreen mode).
     365 *
     366 * @param ui User interface
     367 * @return Active window
     368 */
     369ui_window_t *ui_window_get_active(ui_t *ui)
     370{
     371        link_t *link;
     372
     373        link = list_last(&ui->windows);
     374        if (link == NULL)
     375                return NULL;
     376
     377        return list_get_instance(link, ui_window_t, lwindows);
    364378}
    365379
Note: See TracChangeset for help on using the changeset viewer.