Changeset b1f0a14 in mainline for uspace/app/launcher/launcher.c
- Timestamp:
- 2023-01-22T11:05:28Z (15 months ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0161d16
- Parents:
- 5d380b6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/launcher/launcher.c
r5d380b6 rb1f0a14 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * Copyright (c) 2012 Petr Koupy 4 4 * All rights reserved. … … 59 59 60 60 static void wnd_close(ui_window_t *, void *); 61 static void wnd_pos(ui_window_t *, void *, pos_event_t *); 61 62 62 63 static ui_window_cb_t window_cb = { 63 .close = wnd_close 64 .close = wnd_close, 65 .pos = wnd_pos 64 66 }; 65 67 … … 70 72 }; 71 73 72 static int app_launchl( const char *, ...);74 static int app_launchl(launcher_t *, const char *, ...); 73 75 74 76 /** Window close button was clicked. … … 84 86 } 85 87 88 /** Window received position event. 89 * 90 * @param window Window 91 * @param arg Argument (launcher) 92 * @param event Position event 93 */ 94 static void wnd_pos(ui_window_t *window, void *arg, pos_event_t *event) 95 { 96 launcher_t *launcher = (launcher_t *) arg; 97 98 /* Remember ID of device that sent the last event */ 99 launcher->ev_pos_id = event->pos_id; 100 101 ui_window_def_pos(window, event); 102 } 103 86 104 /** Push button was clicked. 87 105 * … … 94 112 95 113 if (pbutton == launcher->pb1) { 96 app_launchl( "/app/terminal", "-c", "/app/nav", NULL);114 app_launchl(launcher, "/app/terminal", "-c", "/app/nav", NULL); 97 115 } else if (pbutton == launcher->pb2) { 98 app_launchl( "/app/terminal", "-c", "/app/edit", NULL);116 app_launchl(launcher, "/app/terminal", "-c", "/app/edit", NULL); 99 117 } else if (pbutton == launcher->pb3) { 100 app_launchl( "/app/terminal", NULL);118 app_launchl(launcher, "/app/terminal", NULL); 101 119 } else if (pbutton == launcher->pb4) { 102 app_launchl( "/app/calculator", NULL);120 app_launchl(launcher, "/app/calculator", NULL); 103 121 } else if (pbutton == launcher->pb5) { 104 app_launchl( "/app/uidemo", NULL);122 app_launchl(launcher, "/app/uidemo", NULL); 105 123 } else if (pbutton == launcher->pb6) { 106 app_launchl( "/app/gfxdemo", "ui", NULL);107 } 108 } 109 110 static int app_launchl( const char *app, ...)124 app_launchl(launcher, "/app/gfxdemo", "ui", NULL); 125 } 126 } 127 128 static int app_launchl(launcher_t *launcher, const char *app, ...) 111 129 { 112 130 errno_t rc; … … 117 135 const char **argv; 118 136 const char **argp; 137 char *dspec; 119 138 int cnt = 0; 120 139 int i; 140 int rv; 121 141 122 142 va_start(ap, app); … … 137 157 *argp++ = app; 138 158 139 if (str_cmp(display_spec, UI_DISPLAY_DEFAULT) != 0) { 140 *argp++ = "-d"; 141 *argp++ = display_spec; 142 } 159 rv = asprintf(&dspec, "%s?idev=%zu", display_spec, 160 (size_t)launcher->ev_pos_id); 161 if (rv < 0) { 162 printf("Out of memory.\n"); 163 return -1; 164 } 165 166 /* TODO Might be omitted if default display AND only one seat */ 167 *argp++ = "-d"; 168 *argp++ = dspec; 143 169 144 170 va_start(ap, app); … … 192 218 gfx_rect_t rect; 193 219 gfx_coord2_t off; 220 const char *dspec = UI_DISPLAY_DEFAULT; 221 char *qmark; 194 222 errno_t rc; 195 223 … … 204 232 } 205 233 206 d isplay_spec = argv[i++];234 dspec = argv[i++]; 207 235 } else { 208 236 printf("Invalid option '%s'.\n", argv[i]); … … 212 240 } 213 241 214 rc = ui_create(display_spec, &ui); 242 display_spec = str_dup(dspec); 243 if (display_spec == NULL) { 244 printf("Out of memory.\n"); 245 return 1; 246 } 247 248 /* Remove additional arguments */ 249 qmark = str_chr(display_spec, '?'); 250 if (qmark != NULL) 251 *qmark = '\0'; 252 253 rc = ui_create(dspec, &ui); 215 254 if (rc != EOK) { 216 255 printf("Error creating UI on display %s.\n", display_spec);
Note:
See TracChangeset
for help on using the changeset viewer.