Changeset 0ffa40a7 in mainline


Ignore:
Timestamp:
2024-03-08T13:30:18Z (7 weeks ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
3f81cdc
Parents:
0a411bbf
git-author:
Jiri Svoboda <jiri@…> (2024-03-07 20:29:50)
git-committer:
Jiri Svoboda <jiri@…> (2024-03-08 13:30:18)
Message:

Viewer should support console mode

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/viewer/viewer.c

    r0a411bbf r0ffa40a7  
    5656static char **imgs;
    5757
    58 static ui_window_t *window;
     58static ui_window_t *window = NULL;
    5959static gfx_bitmap_t *bitmap = NULL;
    6060static ui_image_t *image = NULL;
     
    9090    kbd_event_t *event)
    9191{
     92        viewer_t *viewer = (viewer_t *)arg;
    9293        bool update = false;
    9394
    9495        if ((event->type == KEY_PRESS) && (event->c == 'q'))
    95                 exit(0);
     96                ui_quit(viewer->ui);
    9697
    9798        if ((event->type == KEY_PRESS) && (event->key == KC_PAGE_DOWN)) {
     
    216217int main(int argc, char *argv[])
    217218{
    218         const char *display_spec = UI_DISPLAY_DEFAULT;
     219        const char *display_spec = UI_ANY_DEFAULT;
    219220        gfx_bitmap_t *lbitmap;
    220221        gfx_rect_t lrect;
     
    277278        }
    278279
     280        if (ui_is_fullscreen(ui))
     281                fullscreen = true;
     282
    279283        viewer.ui = ui;
    280284
     
    298302        if (rc != EOK) {
    299303                printf("Error creating window.\n");
    300                 return 1;
     304                goto error;
    301305        }
    302306
     
    307311        if (!img_load(window_gc, imgs[imgs_current], &lbitmap, &lrect)) {
    308312                printf("Cannot load image \"%s\".\n", imgs[imgs_current]);
    309                 return 1;
     313                goto error;
    310314        }
    311315
     
    322326                if (rc != EOK) {
    323327                        printf("Error resizing window.\n");
    324                         return 1;
     328                        goto error;
    325329                }
    326330        }
     
    328332        if (!img_setup(window_gc, lbitmap, &lrect)) {
    329333                printf("Cannot setup image \"%s\".\n", imgs[imgs_current]);
    330                 return 1;
     334                goto error;
    331335        }
    332336
     
    334338        if (rc != EOK) {
    335339                printf("Error painting window.\n");
    336                 return 1;
     340                goto error;
    337341        }
    338342
    339343        ui_run(ui);
    340344
     345        ui_window_destroy(window);
     346        ui_destroy(ui);
     347
    341348        return 0;
     349error:
     350        if (window != NULL)
     351                ui_window_destroy(window);
     352        ui_destroy(ui);
     353        return 1;
    342354}
    343355
Note: See TracChangeset for help on using the changeset viewer.