Changeset 552b69f in mainline


Ignore:
Timestamp:
2021-11-03T20:56:59Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1aa8c86
Parents:
ec8a1bf
Message:

Dual-mode applications should automatically fall back to console

Location:
uspace
Files:
7 edited

Legend:

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

    rec8a1bf r552b69f  
    787787int main(int argc, char *argv[])
    788788{
    789         const char *display_spec = UI_DISPLAY_DEFAULT;
     789        const char *display_spec = UI_ANY_DEFAULT;
    790790        ui_t *ui;
    791791        ui_resource_t *ui_res;
  • uspace/app/hello/hello.c

    rec8a1bf r552b69f  
    152152int main(int argc, char *argv[])
    153153{
    154         const char *display_spec = UI_DISPLAY_DEFAULT;
     154        const char *display_spec = UI_ANY_DEFAULT;
    155155        errno_t rc;
    156156        int i;
  • uspace/app/launcher/launcher.c

    rec8a1bf r552b69f  
    5656#define NAME  "launcher"
    5757
    58 static char *display_spec = UI_DISPLAY_DEFAULT;
     58static const char *display_spec = UI_DISPLAY_DEFAULT;
    5959
    6060static void wnd_close(ui_window_t *, void *);
     
    137137        *argp++ = app;
    138138
    139         if (display_spec != UI_DISPLAY_DEFAULT) {
     139        if (str_cmp(display_spec, UI_DISPLAY_DEFAULT) != 0) {
    140140                *argp++ = "-d";
    141141                *argp++ = display_spec;
  • uspace/app/uidemo/uidemo.c

    rec8a1bf r552b69f  
    10191019int main(int argc, char *argv[])
    10201020{
    1021         const char *display_spec = UI_DISPLAY_DEFAULT;
     1021        const char *display_spec = UI_ANY_DEFAULT;
    10221022        errno_t rc;
    10231023        int i;
  • uspace/lib/display/src/display.c

    rec8a1bf r552b69f  
    6868                dsname = SERVICE_NAME_DISPLAY;
    6969
    70         rc = loc_service_get_id(dsname, &display_svc, IPC_FLAG_BLOCKING);
     70        rc = loc_service_get_id(dsname, &display_svc, 0);
    7171        if (rc != EOK) {
    7272                free(display);
     
    7575
    7676        display->sess = loc_service_connect(display_svc, INTERFACE_DISPLAY,
    77             IPC_FLAG_BLOCKING);
     77            0);
    7878        if (display->sess == NULL) {
    7979                free(display);
  • uspace/lib/ui/include/types/ui/ui.h

    rec8a1bf r552b69f  
    4343
    4444/** Use the default display service (argument to ui_create()) */
    45 #define UI_DISPLAY_DEFAULT NULL
     45#define UI_DISPLAY_DEFAULT "disp@"
    4646/** Use the default console service (argument to ui_create()) */
    4747#define UI_CONSOLE_DEFAULT "cons@"
     48/** Use any available service (argument to ui_create()) */
     49#define UI_ANY_DEFAULT "@"
    4850/** Use dummy output (argument to ui_create()) */
    4951#define UI_DISPLAY_NULL "null@"
     
    5759        /** Console */
    5860        ui_ws_console,
     61        /** Any non-dummy output backend */
     62        ui_ws_any,
    5963        /** Dummy output */
    6064        ui_ws_null
  • uspace/lib/ui/src/ui.c

    rec8a1bf r552b69f  
    6969        const char *cp;
    7070
    71         if (ospec == UI_DISPLAY_DEFAULT) {
    72                 *ws = ui_ws_display;
    73                 *osvc = DISPLAY_DEFAULT;
    74                 return;
    75         }
    76 
    7771        cp = ospec;
    7872        while (isalpha(*cp))
     
    8680                } else if (str_lcmp(ospec, "null@", str_length("null@")) == 0) {
    8781                        *ws = ui_ws_null;
     82                } else if (str_lcmp(ospec, "@", str_length("@")) == 0) {
     83                        *ws = ui_ws_any;
    8884                } else {
    8985                        *ws = ui_ws_unknown;
     
    123119        ui_ospec_parse(ospec, &ws, &osvc);
    124120
    125         if (ws == ui_ws_display) {
    126                 rc = display_open(osvc, &display);
     121        if (ws == ui_ws_display || ws == ui_ws_any) {
     122                rc = display_open(osvc != NULL ? osvc : DISPLAY_DEFAULT,
     123                    &display);
    127124                if (rc != EOK)
    128                         return rc;
     125                        goto disp_fail;
    129126
    130127                rc = ui_create_disp(display, &ui);
    131128                if (rc != EOK) {
    132129                        display_close(display);
    133                         return rc;
    134                 }
    135         } else if (ws == ui_ws_console) {
     130                        goto disp_fail;
     131                }
     132
     133                ui->myoutput = true;
     134                *rui = ui;
     135                return EOK;
     136        }
     137
     138disp_fail:
     139        if (ws == ui_ws_console || ws == ui_ws_any) {
    136140                console = console_init(stdin, stdout);
    137141                if (console == NULL)
    138                         return EIO;
     142                        goto cons_fail;
    139143
    140144                rc = console_get_size(console, &cols, &rows);
    141145                if (rc != EOK) {
    142146                        console_done(console);
    143                         return rc;
     147                        goto cons_fail;
    144148                }
    145149
     
    150154                if (rc != EOK) {
    151155                        console_done(console);
    152                         return rc;
     156                        goto cons_fail;
    153157                }
    154158
     
    157161                        ui_destroy(ui);
    158162                        console_done(console);
    159                         return rc;
     163                        goto cons_fail;
    160164                }
    161165
     
    167171
    168172                (void) ui_paint(ui);
    169         } else if (ws == ui_ws_null) {
     173                ui->myoutput = true;
     174                *rui = ui;
     175                return EOK;
     176        }
     177
     178cons_fail:
     179        if (ws == ui_ws_null) {
    170180                rc = ui_create_disp(NULL, &ui);
    171181                if (rc != EOK)
    172182                        return rc;
    173         } else {
    174                 return EINVAL;
    175         }
    176 
    177         ui->myoutput = true;
    178         *rui = ui;
    179         return EOK;
     183
     184                ui->myoutput = true;
     185                *rui = ui;
     186                return EOK;
     187        }
     188
     189        return EINVAL;
    180190}
    181191
Note: See TracChangeset for help on using the changeset viewer.