Changes in uspace/app/gfxdemo/gfxdemo.c [d0dfbba:3d588be] in mainline
- File:
-
- 1 edited
-
uspace/app/gfxdemo/gfxdemo.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/gfxdemo/gfxdemo.c
rd0dfbba r3d588be 1 1 /* 2 * Copyright (c) 202 6Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 36 36 #include <display.h> 37 37 #include <fibril.h> 38 #include <fibril_synch.h>39 38 #include <gfx/bitmap.h> 40 39 #include <gfx/color.h> … … 62 61 }; 63 62 64 static void uiwnd_resize_event(ui_window_t *, void *);65 63 static void uiwnd_close_event(ui_window_t *, void *); 66 64 static void uiwnd_kbd_event(ui_window_t *, void *, kbd_event_t *); 67 65 68 66 static ui_window_cb_t ui_window_cb = { 69 .resize = uiwnd_resize_event,70 67 .close = uiwnd_close_event, 71 68 .kbd = uiwnd_kbd_event … … 82 79 static console_ctrl_t *con = NULL; 83 80 static bool textmode; 84 static console_gc_t *cgc = NULL;85 static unsigned scr_width, scr_height;86 81 static ui_t *ui; 87 82 … … 104 99 usec_t usec; 105 100 cons_event_t cevent; 106 sysarg_t cols, rows;107 101 108 102 if (ui != NULL) … … 119 113 demo_kbd_event(&cevent.ev.key); 120 114 fibril_mutex_lock(&quit_lock); 121 } else if (cevent.type == CEV_RESIZE) {122 rc = console_get_size(con,123 &cols, &rows);124 if (rc == EOK) {125 scr_width = cols;126 scr_height = rows;127 }128 rc = console_gc_resize(cgc);129 if (rc != EOK)130 exit(1);131 115 } 132 116 } … … 1040 1024 * 1041 1025 * @param gc Graphic context 1042 */ 1043 static errno_t demo_loop(gfx_context_t *gc) 1044 { 1045 errno_t rc; 1046 1047 (void) demo_font_init(gc, scr_width, scr_height); 1026 * @param w Width 1027 * @param h Height 1028 */ 1029 static errno_t demo_loop(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h) 1030 { 1031 errno_t rc; 1032 1033 (void) demo_font_init(gc, w, h); 1048 1034 1049 1035 while (!quit) { 1050 rc = demo_rects(gc, scr_width, scr_height);1051 if (rc != EOK) 1052 goto error; 1053 1054 rc = demo_bitmap(gc, scr_width, scr_height);1055 if (rc != EOK) 1056 goto error; 1057 1058 rc = demo_bitmap2(gc, scr_width, scr_height);1059 if (rc != EOK) 1060 goto error; 1061 1062 rc = demo_bitmap_kc(gc, scr_width, scr_height);1063 if (rc != EOK) 1064 goto error; 1065 1066 rc = demo_text(gc, scr_width, scr_height);1067 if (rc != EOK) 1068 goto error; 1069 1070 rc = demo_text_abbr(gc, scr_width, scr_height);1071 if (rc != EOK) 1072 goto error; 1073 1074 rc = demo_clip(gc, scr_width, scr_height);1036 rc = demo_rects(gc, w, h); 1037 if (rc != EOK) 1038 goto error; 1039 1040 rc = demo_bitmap(gc, w, h); 1041 if (rc != EOK) 1042 goto error; 1043 1044 rc = demo_bitmap2(gc, w, h); 1045 if (rc != EOK) 1046 goto error; 1047 1048 rc = demo_bitmap_kc(gc, w, h); 1049 if (rc != EOK) 1050 goto error; 1051 1052 rc = demo_text(gc, w, h); 1053 if (rc != EOK) 1054 goto error; 1055 1056 rc = demo_text_abbr(gc, w, h); 1057 if (rc != EOK) 1058 goto error; 1059 1060 rc = demo_clip(gc, w, h); 1075 1061 if (rc != EOK) 1076 1062 goto error; … … 1087 1073 static errno_t demo_console(void) 1088 1074 { 1075 console_gc_t *cgc = NULL; 1089 1076 gfx_context_t *gc; 1090 1077 sysarg_t cols, rows; … … 1108 1095 textmode = true; 1109 1096 1110 scr_width = cols; 1111 scr_height = rows; 1112 1113 rc = demo_loop(gc); 1097 rc = demo_loop(gc, cols, rows); 1114 1098 if (rc != EOK) 1115 1099 return rc; … … 1128 1112 1129 1113 ui_lock(args->ui); 1130 scr_width = args->dims.x; 1131 scr_height = args->dims.y; 1132 rc = demo_loop(args->gc); 1114 rc = demo_loop(args->gc, args->dims.x, args->dims.y); 1133 1115 ui_unlock(args->ui); 1134 1116 ui_quit(args->ui); … … 1172 1154 1173 1155 /* Do not decorate the window in fullscreen mode */ 1174 if (ui_is_fullscreen(ui)) {1156 if (ui_is_fullscreen(ui)) 1175 1157 params.style &= ~ui_wds_decorated; 1176 params.placement = ui_wnd_place_full_screen;1177 }1178 1158 1179 1159 /* … … 1279 1259 textmode = false; 1280 1260 1281 scr_width = 400; 1282 scr_height = 300; 1283 rc = demo_loop(gc); 1261 rc = demo_loop(gc, 400, 300); 1284 1262 if (rc != EOK) 1285 1263 return rc; … … 1333 1311 (void)arg; 1334 1312 demo_kbd_event(event); 1335 }1336 1337 static void uiwnd_resize_event(ui_window_t *window, void *arg)1338 {1339 gfx_rect_t rect;1340 gfx_coord2_t dims;1341 1342 ui_window_get_app_rect(window, &rect);1343 gfx_rect_dims(&rect, &dims);1344 scr_width = dims.x;1345 scr_height = dims.y;1346 1313 } 1347 1314 … … 1388 1355 } 1389 1356 1390 if (i >= argc || str_cmp(argv[i], " ui") == 0) {1391 rc = demo_ ui(ui_display_spec);1357 if (i >= argc || str_cmp(argv[i], "display") == 0) { 1358 rc = demo_display(display_svc); 1392 1359 if (rc != EOK) 1393 1360 return 1; … … 1396 1363 if (rc != EOK) 1397 1364 return 1; 1398 } else if (str_cmp(argv[i], " display") == 0) {1399 rc = demo_ display(display_svc);1365 } else if (str_cmp(argv[i], "ui") == 0) { 1366 rc = demo_ui(ui_display_spec); 1400 1367 if (rc != EOK) 1401 1368 return 1;
Note:
See TracChangeset
for help on using the changeset viewer.
