Changeset fd11144 in mainline for uspace/app/vlaunch/vlaunch.c


Ignore:
Timestamp:
2020-07-04T21:52:35Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fc4abca
Parents:
e79a025
Message:

Make display service argument optional

File:
1 edited

Legend:

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

    re79a025 rfd11144  
    3737#include <stdio.h>
    3838#include <stdlib.h>
     39#include <str.h>
    3940#include <task.h>
    4041#include <str_error.h>
     
    5859#define LOGO_HEIGHT  66
    5960
    60 static char *winreg = NULL;
     61static char *display_svc = DISPLAY_DEFAULT;
    6162
    6263static int app_launch(const char *app)
    6364{
    64         printf("%s: Spawning %s %s \n", NAME, app, winreg);
    65 
     65        errno_t rc;
    6666        task_id_t id;
    6767        task_wait_t wait;
    68         errno_t rc = task_spawnl(&id, &wait, app, app, winreg, NULL);
     68
     69        if (display_svc != DISPLAY_DEFAULT) {
     70                printf("%s: Spawning %s -d %s\n", NAME, app, display_svc);
     71                rc = task_spawnl(&id, &wait, app, app, "-d", display_svc, NULL);
     72        } else {
     73                printf("%s: Spawning %s\n", NAME, app);
     74                rc = task_spawnl(&id, &wait, app, app, NULL);
     75        }
     76
    6977        if (rc != EOK) {
    7078                printf("%s: Error spawning %s %s (%s)\n", NAME, app,
    71                     winreg, str_error(rc));
     79                    display_svc != DISPLAY_DEFAULT ? display_svc :
     80                    "<default>", str_error(rc));
    7281                return -1;
    7382        }
     
    91100}
    92101
     102static void print_syntax(void)
     103{
     104        printf("Syntax: %s [-d <display>]\n", NAME);
     105}
     106
    93107int main(int argc, char *argv[])
    94108{
    95         if (argc < 2) {
    96                 printf("Compositor server not specified.\n");
    97                 return 1;
     109        int i;
     110
     111        i = 1;
     112        while (i < argc) {
     113                if (str_cmp(argv[i], "-d") == 0) {
     114                        ++i;
     115                        if (i >= argc) {
     116                                printf("Argument missing.\n");
     117                                print_syntax();
     118                                return 1;
     119                        }
     120
     121                        display_svc = argv[i++];
     122                } else {
     123                        printf("Invalid option '%s'.\n", argv[i]);
     124                        print_syntax();
     125                        return 1;
     126                }
    98127        }
    99128
     
    104133        }
    105134
    106         winreg = argv[1];
    107         window_t *main_window = window_open(argv[1], NULL,
     135        window_t *main_window = window_open(display_svc, NULL,
    108136            WINDOW_MAIN | WINDOW_DECORATED | WINDOW_RESIZEABLE, "vlaunch");
    109137        if (!main_window) {
Note: See TracChangeset for help on using the changeset viewer.