Changeset fd11144 in mainline
- Timestamp:
- 2020-07-04T21:52:35Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fc4abca
- Parents:
- e79a025
- Location:
- uspace/app
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/barber/barber.c
re79a025 rfd11144 40 40 #include <loc.h> 41 41 #include <stats.h> 42 #include <str.h> 42 43 #include <fibril_synch.h> 43 44 #include <io/pixel.h> … … 247 248 } 248 249 250 static void print_syntax(void) 251 { 252 printf("Syntax: %s [-d <display>]\n", NAME); 253 } 254 249 255 int main(int argc, char *argv[]) 250 256 { 251 if (argc < 2) { 252 printf("Compositor server not specified.\n"); 253 return 1; 257 const char *display_svc = DISPLAY_DEFAULT; 258 int i; 259 260 i = 1; 261 while (i < argc) { 262 if (str_cmp(argv[i], "-d") == 0) { 263 ++i; 264 if (i >= argc) { 265 printf("Argument missing.\n"); 266 print_syntax(); 267 return 1; 268 } 269 270 display_svc = argv[i++]; 271 } else { 272 printf("Invalid option '%s'.\n", argv[i]); 273 print_syntax(); 274 return 1; 275 } 254 276 } 255 277 … … 277 299 278 300 winreg = argv[1]; 279 window_t *main_window = window_open( argv[1], NULL,301 window_t *main_window = window_open(display_svc, NULL, 280 302 WINDOW_MAIN | WINDOW_DECORATED, "barber"); 281 303 if (!main_window) { -
uspace/app/fontviewer/fontviewer.c
re79a025 rfd11144 38 38 #include <stdlib.h> 39 39 #include <stdbool.h> 40 #include <str.h> 40 41 #include <str_error.h> 41 42 #include <window.h> … … 245 246 } 246 247 248 static void print_syntax(void) 249 { 250 printf("Syntax: %s [-d <display>]\n", NAME); 251 } 252 247 253 int main(int argc, char *argv[]) 248 254 { 249 if (argc < 2) { 250 printf("Compositor server not specified.\n"); 251 return 1; 252 } 253 254 if (argc < 3) { 255 const char *display_svc = DISPLAY_DEFAULT; 256 int i; 257 258 i = 1; 259 while (i < argc) { 260 if (str_cmp(argv[i], "-d") == 0) { 261 ++i; 262 if (i >= argc) { 263 printf("Argument missing.\n"); 264 print_syntax(); 265 return 1; 266 } 267 268 display_svc = argv[i++]; 269 } else { 270 printf("Invalid option '%s'.\n", argv[i]); 271 print_syntax(); 272 return 1; 273 } 274 } 275 276 if (i < argc) { 255 277 font_path = NULL; 256 278 } else { 257 font_path = argv[ 2];258 } 259 260 main_window = window_open( argv[1], NULL, WINDOW_MAIN, "fontviewer");279 font_path = argv[i]; 280 } 281 282 main_window = window_open(display_svc, NULL, WINDOW_MAIN, "fontviewer"); 261 283 if (!main_window) { 262 284 printf("Cannot open main window.\n"); -
uspace/app/gfxdemo/gfxdemo.c
re79a025 rfd11144 1 1 /* 2 * Copyright (c) 20 19Jiri Svoboda2 * Copyright (c) 2020 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 487 487 488 488 /** Run demo on canvas. */ 489 static errno_t demo_canvas( void)489 static errno_t demo_canvas(const char *display_svc) 490 490 { 491 491 canvas_gc_t *cgc = NULL; … … 500 500 printf("Init canvas..\n"); 501 501 502 window = window_open( DISPLAY_DEFAULT, NULL,502 window = window_open(display_svc, NULL, 503 503 WINDOW_MAIN | WINDOW_DECORATED, "GFX Demo"); 504 504 if (window == NULL) { … … 553 553 554 554 /** Run demo on display server. */ 555 static errno_t demo_display( void)555 static errno_t demo_display(const char *display_svc) 556 556 { 557 557 display_t *display = NULL; … … 563 563 printf("Init display..\n"); 564 564 565 rc = display_open( DISPLAY_DEFAULT, &display);565 rc = display_open(display_svc, &display); 566 566 if (rc != EOK) { 567 567 printf("Error opening display.\n"); … … 618 618 static void print_syntax(void) 619 619 { 620 printf(" syntax: gfxdemo{canvas|console|display}\n");620 printf("Syntax: gfxdemo [-d <display>] {canvas|console|display}\n"); 621 621 } 622 622 … … 624 624 { 625 625 errno_t rc; 626 627 if (argc < 2 || str_cmp(argv[1], "display") == 0) { 628 rc = demo_display(); 629 if (rc != EOK) 626 const char *display_svc = DISPLAY_DEFAULT; 627 int i; 628 629 i = 1; 630 while (i < argc && argv[i][0] == '-') { 631 if (str_cmp(argv[i], "-d") == 0) { 632 ++i; 633 if (i >= argc) { 634 printf("Argument missing.\n"); 635 print_syntax(); 636 return 1; 637 } 638 639 display_svc = argv[i++]; 640 } else { 641 printf("Invalid option '%s'.\n", argv[i]); 642 print_syntax(); 630 643 return 1; 631 } else if (str_cmp(argv[1], "console") == 0) { 644 } 645 } 646 647 if (i >= argc || str_cmp(argv[i], "display") == 0) { 648 rc = demo_display(display_svc); 649 if (rc != EOK) 650 return 1; 651 } else if (str_cmp(argv[i], "console") == 0) { 632 652 rc = demo_console(); 633 653 if (rc != EOK) 634 654 return 1; 635 } else if (str_cmp(argv[ 1], "canvas") == 0) {636 rc = demo_canvas( );655 } else if (str_cmp(argv[i], "canvas") == 0) { 656 rc = demo_canvas(display_svc); 637 657 if (rc != EOK) 638 658 return 1; -
uspace/app/init/init.c
re79a025 rfd11144 69 69 70 70 #define SRV_DISPLAY "/srv/hid/display" 71 #define DISPLAY_SVC "hid/display"72 71 73 72 #define HID_INPUT "hid/input" … … 278 277 } 279 278 280 static int gui_start(const char *app, const char *display_svc)279 static int app_start(const char *app) 281 280 { 282 281 printf("%s: Spawning %s\n", NAME, app); … … 284 283 task_id_t id; 285 284 task_wait_t wait; 286 errno_t rc = task_spawnl(&id, &wait, app, app, display_svc,NULL);285 errno_t rc = task_spawnl(&id, &wait, app, app, NULL); 287 286 if (rc != EOK) { 288 287 oom_check(rc, app); … … 472 471 rc = display_server(); 473 472 if (rc == EOK) { 474 gui_start("/app/barber", DISPLAY_SVC);475 gui_start("/app/vlaunch", DISPLAY_SVC);476 gui_start("/app/vterm", DISPLAY_SVC);473 app_start("/app/barber"); 474 app_start("/app/vlaunch"); 475 app_start("/app/vterm"); 477 476 } 478 477 } -
uspace/app/vcalc/vcalc.c
re79a025 rfd11144 468 468 } 469 469 470 static void print_syntax(void) 471 { 472 printf("Syntax: %s [-d <display>]\n", NAME); 473 } 474 470 475 int main(int argc, char *argv[]) 471 476 { 472 if (argc < 2) { 473 printf("%s: Compositor server not specified.\n", NAME); 474 return 1; 475 } 476 477 window_t *main_window = window_open(argv[1], NULL, 477 const char *display_svc = DISPLAY_DEFAULT; 478 int i; 479 480 i = 1; 481 while (i < argc) { 482 if (str_cmp(argv[i], "-d") == 0) { 483 ++i; 484 if (i >= argc) { 485 printf("Argument missing.\n"); 486 print_syntax(); 487 return 1; 488 } 489 490 display_svc = argv[i++]; 491 } else { 492 printf("Invalid option '%s'.\n", argv[i]); 493 print_syntax(); 494 return 1; 495 } 496 } 497 498 window_t *main_window = window_open(display_svc, NULL, 478 499 WINDOW_MAIN | WINDOW_DECORATED | WINDOW_RESIZEABLE, NAME); 479 500 if (!main_window) { -
uspace/app/vdemo/vdemo.c
re79a025 rfd11144 1 1 /* 2 * Copyright (c) 2020 Jiri Svoboda 2 3 * Copyright (c) 2012 Petr Koupy 3 4 * All rights reserved. … … 36 37 #include <stdio.h> 37 38 #include <stdlib.h> 39 #include <str.h> 38 40 #include <io/pixel.h> 39 41 #include <task.h> … … 107 109 } 108 110 111 static void print_syntax(void) 112 { 113 printf("Syntax: %s [-d <display>]\n", NAME); 114 } 115 109 116 int main(int argc, char *argv[]) 110 117 { 111 if (argc >= 2) { 112 window_t *main_window = window_open(argv[1], NULL, 113 WINDOW_MAIN | WINDOW_DECORATED | WINDOW_RESIZEABLE, "vdemo"); 114 if (!main_window) { 115 printf("Cannot open main window.\n"); 118 const char *disp_svc = DISPLAY_DEFAULT; 119 int i; 120 121 i = 1; 122 while (i < argc) { 123 if (str_cmp(argv[i], "-d") == 0) { 124 ++i; 125 if (i >= argc) { 126 printf("Argument missing.\n"); 127 print_syntax(); 128 return 1; 129 } 130 131 disp_svc = argv[i++]; 132 } else { 133 printf("Invalid option '%s'.\n", argv[i]); 134 print_syntax(); 116 135 return 1; 117 136 } 137 } 118 138 119 pixel_t grd_bg = PIXEL(255, 240, 240, 240); 120 121 pixel_t btn_bg = PIXEL(255, 240, 240, 240); 122 pixel_t btn_fg = PIXEL(255, 186, 186, 186); 123 pixel_t btn_text = PIXEL(255, 0, 0, 0); 124 125 pixel_t lbl_bg = PIXEL(255, 240, 240, 240); 126 pixel_t lbl_text = PIXEL(255, 0, 0, 0); 127 128 my_label_t *lbl_action = create_my_label(NULL, "Hello there!", 16, 129 lbl_bg, lbl_text); 130 button_t *btn_confirm = create_button(NULL, NULL, "Confirm", 16, 131 btn_bg, btn_fg, btn_text); 132 button_t *btn_cancel = create_button(NULL, NULL, "Cancel", 16, 133 btn_bg, btn_fg, btn_text); 134 grid_t *grid = create_grid(window_root(main_window), NULL, 2, 2, 135 grd_bg); 136 if (!lbl_action || !btn_confirm || !btn_cancel || !grid) { 137 window_close(main_window); 138 printf("Cannot create widgets.\n"); 139 return 1; 140 } 141 142 sig_connect( 143 &btn_confirm->clicked, 144 &lbl_action->label.widget, 145 lbl_action->confirm); 146 sig_connect( 147 &btn_cancel->clicked, 148 &lbl_action->label.widget, 149 lbl_action->cancel); 150 151 grid->add(grid, &lbl_action->label.widget, 0, 0, 2, 1); 152 grid->add(grid, &btn_confirm->widget, 0, 1, 1, 1); 153 grid->add(grid, &btn_cancel->widget, 1, 1, 1, 1); 154 window_resize(main_window, 0, 0, 200, 76, 155 WINDOW_PLACEMENT_CENTER); 156 157 window_exec(main_window); 158 task_retval(0); 159 async_manager(); 160 return 1; 161 } else { 162 printf("Compositor server not specified.\n"); 139 window_t *main_window = window_open(disp_svc, NULL, 140 WINDOW_MAIN | WINDOW_DECORATED | WINDOW_RESIZEABLE, "vdemo"); 141 if (!main_window) { 142 printf("Cannot open main window.\n"); 163 143 return 1; 164 144 } 145 146 pixel_t grd_bg = PIXEL(255, 240, 240, 240); 147 148 pixel_t btn_bg = PIXEL(255, 240, 240, 240); 149 pixel_t btn_fg = PIXEL(255, 186, 186, 186); 150 pixel_t btn_text = PIXEL(255, 0, 0, 0); 151 152 pixel_t lbl_bg = PIXEL(255, 240, 240, 240); 153 pixel_t lbl_text = PIXEL(255, 0, 0, 0); 154 155 my_label_t *lbl_action = create_my_label(NULL, "Hello there!", 16, 156 lbl_bg, lbl_text); 157 button_t *btn_confirm = create_button(NULL, NULL, "Confirm", 16, 158 btn_bg, btn_fg, btn_text); 159 button_t *btn_cancel = create_button(NULL, NULL, "Cancel", 16, 160 btn_bg, btn_fg, btn_text); 161 grid_t *grid = create_grid(window_root(main_window), NULL, 2, 2, 162 grd_bg); 163 if (!lbl_action || !btn_confirm || !btn_cancel || !grid) { 164 window_close(main_window); 165 printf("Cannot create widgets.\n"); 166 return 1; 167 } 168 169 sig_connect( 170 &btn_confirm->clicked, 171 &lbl_action->label.widget, 172 lbl_action->confirm); 173 sig_connect( 174 &btn_cancel->clicked, 175 &lbl_action->label.widget, 176 lbl_action->cancel); 177 178 grid->add(grid, &lbl_action->label.widget, 0, 0, 2, 1); 179 grid->add(grid, &btn_confirm->widget, 0, 1, 1, 1); 180 grid->add(grid, &btn_cancel->widget, 1, 1, 1, 1); 181 window_resize(main_window, 0, 0, 200, 76, 182 WINDOW_PLACEMENT_CENTER); 183 184 window_exec(main_window); 185 task_retval(0); 186 async_manager(); 187 return 0; 165 188 } 166 189 -
uspace/app/viewer/viewer.c
re79a025 rfd11144 176 176 } 177 177 178 static void print_syntax(void) 179 { 180 printf("Syntax: %s [-d <display>] <image-file>...\n", NAME); 181 } 182 178 183 int main(int argc, char *argv[]) 179 184 { 185 const char *display_svc = DISPLAY_DEFAULT; 180 186 window_flags_t flags; 181 187 surface_t *lsface; … … 183 189 sysarg_t dwidth; 184 190 sysarg_t dheight; 185 186 if (argc < 2) { 187 printf("Compositor server not specified.\n"); 191 int i; 192 193 i = 1; 194 while (i < argc && argv[i][0] == '-') { 195 if (str_cmp(argv[i], "-d") == 0) { 196 ++i; 197 if (i >= argc) { 198 printf("Argument missing.\n"); 199 print_syntax(); 200 return 1; 201 } 202 203 display_svc = argv[i++]; 204 } else { 205 printf("Invalid option '%s'.\n", argv[i]); 206 print_syntax(); 207 return 1; 208 } 209 } 210 211 if (i >= argc) { 212 printf("No image files specified.\n"); 213 print_syntax(); 188 214 return 1; 189 215 } 190 216 191 if (argc < 3) { 192 printf("No image files specified.\n"); 193 return 1; 194 } 195 196 imgs_count = argc - 2; 217 imgs_count = argc - i; 197 218 imgs = calloc(imgs_count, sizeof(char *)); 198 219 if (imgs == NULL) { … … 201 222 } 202 223 203 for (int i = 0; i < argc - 2; i++) {204 imgs[ i] = str_dup(argv[i + 2]);205 if (imgs[ i] == NULL) {224 for (int j = 0; j < argc - i; j++) { 225 imgs[j] = str_dup(argv[i + j]); 226 if (imgs[j] == NULL) { 206 227 printf("Out of memory.\n"); 207 228 return 3; … … 221 242 flags |= WINDOW_DECORATED; 222 243 223 main_window = window_open( argv[1], NULL, flags, "viewer");244 main_window = window_open(display_svc, NULL, flags, "viewer"); 224 245 if (!main_window) { 225 246 printf("Cannot open main window.\n"); -
uspace/app/vlaunch/vlaunch.c
re79a025 rfd11144 37 37 #include <stdio.h> 38 38 #include <stdlib.h> 39 #include <str.h> 39 40 #include <task.h> 40 41 #include <str_error.h> … … 58 59 #define LOGO_HEIGHT 66 59 60 60 static char * winreg = NULL;61 static char *display_svc = DISPLAY_DEFAULT; 61 62 62 63 static int app_launch(const char *app) 63 64 { 64 printf("%s: Spawning %s %s \n", NAME, app, winreg); 65 65 errno_t rc; 66 66 task_id_t id; 67 67 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 69 77 if (rc != EOK) { 70 78 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)); 72 81 return -1; 73 82 } … … 91 100 } 92 101 102 static void print_syntax(void) 103 { 104 printf("Syntax: %s [-d <display>]\n", NAME); 105 } 106 93 107 int main(int argc, char *argv[]) 94 108 { 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 } 98 127 } 99 128 … … 104 133 } 105 134 106 winreg = argv[1]; 107 window_t *main_window = window_open(argv[1], NULL, 135 window_t *main_window = window_open(display_svc, NULL, 108 136 WINDOW_MAIN | WINDOW_DECORATED | WINDOW_RESIZEABLE, "vlaunch"); 109 137 if (!main_window) { -
uspace/app/vterm/vterm.c
re79a025 rfd11144 1 1 /* 2 * Copyright (c) 2020 Jiri Svoboda 2 3 * Copyright (c) 2012 Petr Koupy 3 4 * All rights reserved. … … 42 43 #define NAME "vterm" 43 44 45 static void print_syntax(void) 46 { 47 printf("Syntax: %s [-d <display>]\n", NAME); 48 } 49 44 50 int main(int argc, char *argv[]) 45 51 { 46 if (argc < 2) { 47 printf("%s: Compositor server not specified.\n", NAME); 48 return 1; 52 const char *display_svc = DISPLAY_DEFAULT; 53 int i; 54 55 i = 1; 56 while (i < argc) { 57 if (str_cmp(argv[i], "-d") == 0) { 58 ++i; 59 if (i >= argc) { 60 printf("Argument missing.\n"); 61 print_syntax(); 62 return 1; 63 } 64 65 display_svc = argv[i++]; 66 } else { 67 printf("Invalid option '%s'.\n", argv[i]); 68 print_syntax(); 69 return 1; 70 } 49 71 } 50 72 51 window_t *main_window = window_open( argv[1], NULL,73 window_t *main_window = window_open(display_svc, NULL, 52 74 WINDOW_MAIN | WINDOW_DECORATED, "vterm"); 53 75 if (!main_window) {
Note:
See TracChangeset
for help on using the changeset viewer.