Changes in / [e4cc266:34aad53d] in mainline
- Files:
-
- 36 added
- 5 deleted
- 49 edited
Legend:
- Unmodified
- Added
- Removed
-
README.md
re4cc266 r34aad53d 10 10 extensible, fault tolerant and easy to understand. 11 11 12 ![screenshot](http://www.helenos.org/raw-attachment/wiki/Screenshots/ newgui-aio.png "Screenshot")12 ![screenshot](http://www.helenos.org/raw-attachment/wiki/Screenshots/gui-14.1-aio.png "Screenshot") 13 13 14 14 HelenOS aims to be compatible with the C11 and C++14 standards, but does not -
abi/include/abi/ipc/interfaces.h
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * Copyright (c) 2014 Martin Decky 4 4 * All rights reserved. … … 201 201 INTERFACE_WNDMGT_CB = 202 202 FOURCC_COMPACT('w', 'm', 'g', 't') | IFACE_EXCHANGE_SERIALIZE | IFACE_MOD_CALLBACK, 203 INTERFACE_TBARCFG_NOTIFY = 204 FOURCC_COMPACT('t', 'b', 'c', 'f') | IFACE_EXCHANGE_SERIALIZE, 203 205 INTERFACE_PCAP_CONTROL = 204 206 FOURCC_COMPACT('p', 'c', 't', 'l') | IFACE_EXCHANGE_SERIALIZE, -
defaults/ia64/Makefile.config
re4cc266 r34aad53d 51 51 52 52 # Optimization level 53 OPTIMIZATION = 353 OPTIMIZATION = 2 -
meson/part/initrd_manifest/meson.build
re4cc266 r34aad53d 68 68 if CONFIG_FB 69 69 rd_essential += [ 70 'app/ launcher',70 'app/taskbar', 71 71 'app/terminal', 72 72 -
tools/export.sh
re4cc266 r34aad53d 43 43 uspace/lib/libc.a \ 44 44 uspace/lib/libcongfx.a \ 45 uspace/lib/libconsole.a \ 45 46 uspace/lib/libcpp.a \ 46 47 uspace/lib/libdisplay.a \ … … 48 49 uspace/lib/libgfxfont.a \ 49 50 uspace/lib/libgfximage.a \ 51 uspace/lib/libinput.a \ 50 52 uspace/lib/libhound.a \ 51 53 uspace/lib/libipcgfx.a \ 52 54 uspace/lib/libmath.a \ 53 55 uspace/lib/libmemgfx.a \ 56 uspace/lib/liboutput.a \ 54 57 uspace/lib/libpcm.a \ 55 58 uspace/lib/libpixconv.a \ -
tools/mkarray.py
re4cc266 r34aad53d 39 39 def usage(prname): 40 40 "Print usage syntax" 41 print("%s [--deflate] <DESTINATION> < LABEL> <AS_PROLOG> <SECTION> [SOURCE ...]" % prname)41 print("%s [--deflate] <DESTINATION> <TYPENAME> <LABEL> <AS_PROLOG> <SECTION> [SOURCE ...]" % prname) 42 42 43 43 def arg_check(): 44 if (len(sys.argv) < 5):44 if (len(sys.argv) < 6): 45 45 usage(sys.argv[0]) 46 46 sys.exit() … … 66 66 67 67 dest = sys.argv[1] 68 label = sys.argv[2] 69 as_prolog = sys.argv[3] 70 section = sys.argv[4] 68 typename = sys.argv[2] 69 label = sys.argv[3] 70 as_prolog = sys.argv[4] 71 section = sys.argv[5] 71 72 72 73 timestamp = (1980, 1, 1, 0, 0, 0) … … 81 82 archive = zipfile.ZipFile("%s.zip" % dest, "w", zipfile.ZIP_STORED) 82 83 83 for src in sys.argv[ 5:]:84 for src in sys.argv[6:]: 84 85 basename = os.path.basename(src) 85 86 plainname = os.path.splitext(basename)[0] … … 147 148 data += "#include <stdbool.h>\n\n" 148 149 data += "#define %sS %u\n\n" % (label.upper(), src_cnt) 150 data += "#ifndef %sS_T_\n" % typename.upper() 151 data += "#define %sS_T_\n\n" % typename.upper() 149 152 data += "typedef struct {\n" 150 153 data += "\tconst char *name;\n" … … 153 156 data += "\tsize_t inflated;\n" 154 157 data += "\tbool compressed;\n" 155 data += "} %s_t;\n\n" % label 156 data += "extern %s_t %ss[];\n\n" % (label, label) 158 data += "} %s_t;\n\n" % typename 159 data += "#endif\n" 160 data += "extern %s_t %ss[];\n\n" % (typename, label) 157 161 data += "\n".join(header_ctx) 158 162 data += "\n\n" … … 179 183 data += ' */\n\n' 180 184 data += "#include \"%s.h\"\n\n" % dest 181 data += "%s_t %ss[] = {\n" % ( label, label)185 data += "%s_t %ss[] = {\n" % (typename, label) 182 186 data += ",\n".join(desc_ctx) 183 187 data += "\n" -
tools/mkarray_for_meson.sh
re4cc266 r34aad53d 42 42 _arg3="$4" 43 43 _arg4="$5" 44 _arg5="$6" 44 45 _inputs="" 45 46 46 shift 547 shift 6 47 48 48 49 for file in "$@"; do … … 51 52 52 53 cd $_outdir 53 $TOOLS_DIR/mkarray.py "$_arg1" "$_arg2" "$_arg3" "$_arg4" $_inputs > /dev/null54 $TOOLS_DIR/mkarray.py "$_arg1" "$_arg2" "$_arg3" "$_arg4" "$_arg5" $_inputs > /dev/null -
tools/xcw/bin/helenos-pkg-config
re4cc266 r34aad53d 93 93 config = args.parse_args() 94 94 95 export_dir = os.getenv('EXPORT_DIR', get_build_root() )95 export_dir = os.getenv('EXPORT_DIR', get_build_root() + '/export') 96 96 97 97 result = [] -
uspace/app/barber/barber.c
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * Copyright (c) 2014 Martin Decky 4 4 * All rights reserved. … … 50 50 #include <ui/image.h> 51 51 #include "images.h" 52 #include "images_tiny.h" 52 53 53 54 #define NAME "barber" … … 60 61 #define MIN_LOAD (LOAD_UNIT / 4) 61 62 #define MAX_LOAD (LOAD_UNIT / 3) 62 63 #define FRAME_WIDTH 5964 #define FRAME_HEIGHT 19265 63 66 64 #define LED_PERIOD 1000000 … … 97 95 static unsigned int frame = 0; 98 96 static unsigned int fps = MIN_FPS; 97 static gfx_coord_t frame_width; 98 static gfx_coord_t frame_height; 99 99 100 100 static void led_timer_callback(void *); … … 102 102 103 103 static void wnd_close(ui_window_t *, void *); 104 static void wnd_kbd_event(ui_window_t *, void *, kbd_event_t *); 104 105 105 106 static ui_window_cb_t window_cb = { 106 .close = wnd_close 107 .close = wnd_close, 108 .kbd = wnd_kbd_event 107 109 }; 108 110 … … 110 112 * 111 113 * @param window Window 112 * @param arg Argument ( launcher)114 * @param arg Argument (barber) 113 115 */ 114 116 static void wnd_close(ui_window_t *window, void *arg) … … 119 121 } 120 122 121 static bool decode_frames(gfx_context_t *gc) 123 /** Barber unmodified key press. 124 * 125 * @param barber Barber 126 * @param event Keyboard event 127 */ 128 static void barber_kbd_event_unmod(barber_t *barber, kbd_event_t *event) 129 { 130 if (event->key == KC_ESCAPE) 131 ui_quit(barber->ui); 132 } 133 134 /** Barber ctrl-key key press. 135 * 136 * @param barber Barber 137 * @param event Keyboard event 138 */ 139 static void barber_kbd_event_ctrl(barber_t *barber, kbd_event_t *event) 140 { 141 if (event->key == KC_Q) 142 ui_quit(barber->ui); 143 } 144 145 /** Barber window keyboard event. 146 * 147 * @param window UI window 148 * @param arg Argument (barber_t *) 149 * @param event Keyboard event 150 */ 151 static void wnd_kbd_event(ui_window_t *window, void *arg, kbd_event_t *event) 152 { 153 barber_t *barber = (barber_t *)arg; 154 155 if (event->type != KEY_PRESS) 156 return; 157 158 if ((event->mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) 159 barber_kbd_event_unmod(barber, event); 160 161 if ((event->mods & KM_CTRL) != 0 && 162 (event->mods & (KM_ALT | KM_SHIFT)) == 0) 163 barber_kbd_event_ctrl(barber, event); 164 165 ui_window_def_kbd(window, event); 166 } 167 168 static bool decode_frames(gfx_context_t *gc, image_t *img) 122 169 { 123 170 gfx_rect_t rect; … … 125 172 126 173 for (unsigned int i = 0; i < FRAMES; i++) { 127 rc = decode_tga_gz(gc, im ages[i].addr, images[i].size,174 rc = decode_tga_gz(gc, img[i].addr, img[i].size, 128 175 &frame_bmp[i], &rect); 129 176 if (rc != EOK) { … … 132 179 } 133 180 134 (void) 181 (void)rect; 135 182 } 136 183 … … 238 285 rect.p0.x = 0; 239 286 rect.p0.y = 0; 240 rect.p1.x = FRAME_WIDTH;241 rect.p1.y = FRAME_HEIGHT;287 rect.p1.x = frame_width; 288 rect.p1.y = frame_height; 242 289 243 290 ui_image_set_bmp(frame_img, frame_bmp[frame], &rect); … … 299 346 int main(int argc, char *argv[]) 300 347 { 301 const char *display_spec = UI_ DISPLAY_DEFAULT;348 const char *display_spec = UI_ANY_DEFAULT; 302 349 barber_t barber; 303 350 ui_t *ui; … … 310 357 gfx_context_t *gc; 311 358 gfx_coord2_t off; 359 image_t *img; 312 360 int i; 313 361 … … 355 403 } 356 404 405 if (ui_is_textmode(ui)) { 406 frame_width = 10; 407 frame_height = 16; 408 } else { 409 frame_width = 59; 410 frame_height = 192; 411 } 412 357 413 rect.p0.x = 0; 358 414 rect.p0.y = 0; 359 rect.p1.x = FRAME_WIDTH;360 rect.p1.y = FRAME_HEIGHT;415 rect.p1.x = frame_width; 416 rect.p1.y = frame_height; 361 417 362 418 ui_wnd_params_init(¶ms); … … 367 423 * to rect 368 424 */ 369 ui_wdecor_rect_from_app( params.style, &rect, &wrect);425 ui_wdecor_rect_from_app(ui, params.style, &rect, &wrect); 370 426 off = wrect.p0; 371 427 gfx_rect_rtranslate(&off, &wrect, ¶ms.rect); … … 384 440 ui_window_set_cb(window, &window_cb, (void *) &barber); 385 441 386 if (!decode_frames(gc)) 442 img = ui_is_textmode(ui) ? image_tinys : images; 443 444 if (!decode_frames(gc, img)) 387 445 return 1; 388 446 -
uspace/app/barber/meson.build
re4cc266 r34aad53d 62 62 ) 63 63 64 _images_tiny = files( 65 'gfx-tiny/frame01t.tga.gz', 66 'gfx-tiny/frame02t.tga.gz', 67 'gfx-tiny/frame03t.tga.gz', 68 'gfx-tiny/frame04t.tga.gz', 69 'gfx-tiny/frame05t.tga.gz', 70 'gfx-tiny/frame06t.tga.gz', 71 'gfx-tiny/frame07t.tga.gz', 72 'gfx-tiny/frame08t.tga.gz', 73 'gfx-tiny/frame09t.tga.gz', 74 'gfx-tiny/frame10t.tga.gz', 75 'gfx-tiny/frame11t.tga.gz', 76 'gfx-tiny/frame12t.tga.gz', 77 'gfx-tiny/frame13t.tga.gz', 78 'gfx-tiny/frame14t.tga.gz', 79 'gfx-tiny/frame15t.tga.gz', 80 'gfx-tiny/frame16t.tga.gz', 81 'gfx-tiny/frame17t.tga.gz', 82 'gfx-tiny/frame18t.tga.gz', 83 'gfx-tiny/frame19t.tga.gz', 84 'gfx-tiny/frame20t.tga.gz', 85 'gfx-tiny/frame21t.tga.gz', 86 'gfx-tiny/frame22t.tga.gz', 87 'gfx-tiny/frame23t.tga.gz', 88 'gfx-tiny/frame24t.tga.gz', 89 'gfx-tiny/frame25t.tga.gz', 90 'gfx-tiny/frame26t.tga.gz', 91 'gfx-tiny/frame27t.tga.gz', 92 'gfx-tiny/frame28t.tga.gz', 93 'gfx-tiny/frame29t.tga.gz', 94 'gfx-tiny/frame30t.tga.gz', 95 ) 96 64 97 _tarball = custom_target('barber_images.tar', 65 98 input: _images, … … 70 103 # TODO 71 104 105 # Normal images 106 72 107 _images_zip = custom_target('barber_images.zip', 73 108 input : _images, 74 109 output : [ 'images.zip' ], 75 command : [ mkarray, '@OUTDIR@', 'images', 'image', uspace_as_prolog, '.data', '@INPUT@' ],110 command : [ mkarray, '@OUTDIR@', 'images', 'image', 'image', uspace_as_prolog, '.data', '@INPUT@' ], 76 111 ) 77 112 _imgs_s = custom_target('barber_images.s', … … 94 129 ) 95 130 96 src = [ files('barber.c'), _imgs_s, _imgs_h, _imgs_desc_c ] 131 # Tiny images 132 133 _images_tiny_zip = custom_target('barber_images_tiny.zip', 134 input : _images_tiny, 135 output : [ 'images_tiny.zip' ], 136 command : [ mkarray, '@OUTDIR@', 'images_tiny', 'image', 'image_tiny', uspace_as_prolog, '.data', '@INPUT@' ], 137 ) 138 _imgs_tiny_s = custom_target('barber_images_tiny.s', 139 input : _images_tiny_zip, 140 output : [ 'images_tiny.s' ], 141 command : [ unzip, '-p', '@INPUT@', 'images_tiny.s' ], 142 capture : true, 143 ) 144 _imgs_tiny_h = custom_target('barber_images_tiny.h', 145 input : _images_tiny_zip, 146 output : [ 'images_tiny.h' ], 147 command : [ unzip, '-p', '@INPUT@', 'images_tiny.h' ], 148 capture : true, 149 ) 150 _imgs_tiny_desc_c = custom_target('barber_images_tiny_desc.c', 151 input : _images_tiny_zip, 152 output : [ 'images_tiny_desc.c' ], 153 command : [ unzip, '-p', '@INPUT@', 'images_tiny_desc.c' ], 154 capture : true, 155 ) 156 157 src = [ files('barber.c'), _imgs_s, _imgs_h, _imgs_desc_c, 158 _imgs_tiny_s, _imgs_tiny_h, _imgs_tiny_desc_c ] -
uspace/app/fontedit/fontedit.c
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 202 2Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 787 787 * to rect 788 788 */ 789 ui_wdecor_rect_from_app( params.style, &rect, &wrect);789 ui_wdecor_rect_from_app(ui, params.style, &rect, &wrect); 790 790 off = wrect.p0; 791 791 gfx_rect_rtranslate(&off, &wrect, ¶ms.rect); -
uspace/app/gfxdemo/gfxdemo.c
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 393 393 for (j = 0; j < h; j++) { 394 394 pixelmap_put_pixel(&pixelmap, i, j, 395 PIXEL( 0, (i % 30) < 3 ? 255 : 0,395 PIXEL(255, (i % 30) < 3 ? 255 : 0, 396 396 (j % 30) < 3 ? 255 : 0, i / 2)); 397 397 } … … 429 429 k = i * i + j * j; 430 430 pixelmap_put_pixel(&pixelmap, i, j, 431 PIXEL( 0, k, k, k));431 PIXEL(255, k, k, k)); 432 432 } 433 433 } … … 464 464 k = i * i + j * j; 465 465 pixelmap_put_pixel(&pixelmap, i, j, 466 k < w * w / 2 ? PIXEL( 0, 0, 255, 0) :467 PIXEL( 0, 255, 0, 255));466 k < w * w / 2 ? PIXEL(255, 0, 255, 0) : 467 PIXEL(255, 255, 0, 255)); 468 468 } 469 469 } … … 621 621 params.rect.p1.y = 40; 622 622 params.flags = bmpf_color_key; 623 params.key_color = PIXEL( 0, 255, 0, 255);623 params.key_color = PIXEL(255, 255, 0, 255); 624 624 625 625 rc = gfx_bitmap_create(gc, ¶ms, NULL, &bitmap); … … 1160 1160 * to rect 1161 1161 */ 1162 ui_wdecor_rect_from_app( params.style, &rect, &wrect);1162 ui_wdecor_rect_from_app(ui, params.style, &rect, &wrect); 1163 1163 off = wrect.p0; 1164 1164 gfx_rect_rtranslate(&off, &wrect, ¶ms.rect); -
uspace/app/init/init.c
re4cc266 r34aad53d 476 476 rc = display_server(); 477 477 if (rc == EOK) { 478 app_start("/app/launcher", NULL);479 478 app_start("/app/taskbar", NULL); 480 479 app_start("/app/terminal", "-topleft"); -
uspace/app/meson.build
re4cc266 r34aad53d 28 28 29 29 apps = [ 30 'aboutos', 30 31 'barber', 31 32 'bdsh', … … 57 58 'killall', 58 59 'kio', 59 'launcher',60 60 'loc', 61 61 'logset', -
uspace/app/nav/test/panel.c
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 202 2Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 55 55 PCUT_TEST(create_destroy) 56 56 { 57 panel_t *panel; 58 errno_t rc; 59 60 rc = panel_create(NULL, true, &panel); 61 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 62 63 panel_destroy(panel); 57 ui_t *ui; 58 ui_window_t *window; 59 ui_wnd_params_t params; 60 panel_t *panel; 61 errno_t rc; 62 63 rc = ui_create_disp(NULL, &ui); 64 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 65 66 ui_wnd_params_init(¶ms); 67 params.caption = "Test"; 68 69 rc = ui_window_create(ui, ¶ms, &window); 70 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 71 72 rc = panel_create(window, true, &panel); 73 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 74 75 panel_destroy(panel); 76 ui_window_destroy(window); 77 ui_destroy(ui); 64 78 } 65 79 … … 67 81 PCUT_TEST(set_cb) 68 82 { 83 ui_t *ui; 84 ui_window_t *window; 85 ui_wnd_params_t params; 69 86 panel_t *panel; 70 87 errno_t rc; 71 88 test_resp_t resp; 72 89 73 rc = panel_create(NULL, true, &panel); 90 rc = ui_create_disp(NULL, &ui); 91 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 92 93 ui_wnd_params_init(¶ms); 94 params.caption = "Test"; 95 96 rc = ui_window_create(ui, ¶ms, &window); 97 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 98 99 rc = panel_create(window, true, &panel); 74 100 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 75 101 … … 79 105 80 106 panel_destroy(panel); 107 ui_window_destroy(window); 108 ui_destroy(ui); 81 109 } 82 110 … … 113 141 PCUT_TEST(ctl) 114 142 { 143 ui_t *ui; 144 ui_window_t *window; 145 ui_wnd_params_t params; 115 146 panel_t *panel; 116 147 ui_control_t *control; 117 148 errno_t rc; 118 149 119 rc = panel_create(NULL, true, &panel); 150 rc = ui_create_disp(NULL, &ui); 151 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 152 153 ui_wnd_params_init(¶ms); 154 params.caption = "Test"; 155 156 rc = ui_window_create(ui, ¶ms, &window); 157 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 158 159 rc = panel_create(window, true, &panel); 120 160 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 121 161 … … 124 164 125 165 panel_destroy(panel); 166 ui_window_destroy(window); 167 ui_destroy(ui); 126 168 } 127 169 … … 129 171 PCUT_TEST(kbd_event) 130 172 { 173 ui_t *ui; 174 ui_window_t *window; 175 ui_wnd_params_t params; 131 176 panel_t *panel; 132 177 ui_evclaim_t claimed; … … 136 181 /* Active panel should claim events */ 137 182 138 rc = panel_create(NULL, true, &panel); 183 rc = ui_create_disp(NULL, &ui); 184 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 185 186 ui_wnd_params_init(¶ms); 187 params.caption = "Test"; 188 189 rc = ui_window_create(ui, ¶ms, &window); 190 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 191 192 rc = panel_create(window, true, &panel); 139 193 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 140 194 … … 151 205 /* Inactive panel should not claim events */ 152 206 153 rc = panel_create( NULL, false, &panel);207 rc = panel_create(window, false, &panel); 154 208 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 155 209 … … 163 217 164 218 panel_destroy(panel); 219 ui_window_destroy(window); 220 ui_destroy(ui); 165 221 } 166 222 … … 173 229 PCUT_TEST(set_rect) 174 230 { 231 ui_t *ui; 232 ui_window_t *window; 233 ui_wnd_params_t params; 175 234 panel_t *panel; 176 235 gfx_rect_t rect; 177 236 errno_t rc; 178 237 179 rc = panel_create(NULL, true, &panel); 238 rc = ui_create_disp(NULL, &ui); 239 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 240 241 ui_wnd_params_init(¶ms); 242 params.caption = "Test"; 243 244 rc = ui_window_create(ui, ¶ms, &window); 245 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 246 247 rc = panel_create(window, true, &panel); 180 248 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 181 249 … … 192 260 193 261 panel_destroy(panel); 262 ui_window_destroy(window); 263 ui_destroy(ui); 194 264 } 195 265 … … 197 267 PCUT_TEST(is_active) 198 268 { 199 panel_t *panel; 200 errno_t rc; 201 202 rc = panel_create(NULL, true, &panel); 269 ui_t *ui; 270 ui_window_t *window; 271 ui_wnd_params_t params; 272 panel_t *panel; 273 errno_t rc; 274 275 rc = ui_create_disp(NULL, &ui); 276 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 277 278 ui_wnd_params_init(¶ms); 279 params.caption = "Test"; 280 281 rc = ui_window_create(ui, ¶ms, &window); 282 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 283 284 rc = panel_create(window, true, &panel); 203 285 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 204 286 PCUT_ASSERT_TRUE(panel_is_active(panel)); 205 287 panel_destroy(panel); 206 288 207 rc = panel_create( NULL, false, &panel);289 rc = panel_create(window, false, &panel); 208 290 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 209 291 PCUT_ASSERT_FALSE(panel_is_active(panel)); 210 292 panel_destroy(panel); 293 ui_window_destroy(window); 294 ui_destroy(ui); 211 295 } 212 296 … … 275 359 PCUT_TEST(activate_req) 276 360 { 361 ui_t *ui; 362 ui_window_t *window; 363 ui_wnd_params_t params; 277 364 panel_t *panel; 278 365 errno_t rc; 279 366 test_resp_t resp; 280 367 281 rc = panel_create(NULL, true, &panel); 368 rc = ui_create_disp(NULL, &ui); 369 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 370 371 ui_wnd_params_init(¶ms); 372 params.caption = "Test"; 373 374 rc = ui_window_create(ui, ¶ms, &window); 375 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 376 377 rc = panel_create(window, true, &panel); 282 378 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 283 379 … … 292 388 293 389 panel_destroy(panel); 390 ui_window_destroy(window); 391 ui_destroy(ui); 294 392 } 295 393 -
uspace/app/taskbar-cfg/smeedit.c
re4cc266 r34aad53d 403 403 404 404 startmenu_repaint(smee->startmenu); 405 (void)tbarcfg_notify(TBARCFG_NOTIFY_DEFAULT); 405 406 } else { 406 407 /* Edit existing entry */ … … 419 420 (void)smenu_entry_save(smee->smentry->entry); 420 421 startmenu_entry_update(smee->smentry); 422 (void)tbarcfg_notify(TBARCFG_NOTIFY_DEFAULT); 421 423 } 422 424 -
uspace/app/taskbar-cfg/startmenu.c
re4cc266 r34aad53d 515 515 516 516 (void)smee; 517 (void)tbarcfg_notify(TBARCFG_NOTIFY_DEFAULT); 517 518 } 518 519 … … 533 534 (void)startmenu_insert(smenu, entry, &smentry); 534 535 (void)ui_control_paint(ui_list_ctl(smenu->entries_list)); 536 (void)tbarcfg_notify(TBARCFG_NOTIFY_DEFAULT); 535 537 } 536 538 … … 633 635 free(smentry); 634 636 (void)ui_control_paint(ui_list_ctl(smenu->entries_list)); 637 (void)tbarcfg_notify(TBARCFG_NOTIFY_DEFAULT); 635 638 } 636 639 … … 685 688 686 689 (void)ui_control_paint(ui_list_ctl(smenu->entries_list)); 690 (void)tbarcfg_notify(TBARCFG_NOTIFY_DEFAULT); 687 691 } 688 692 … … 704 708 return; 705 709 706 rc = smenu_entry_move_ up(smentry->entry);710 rc = smenu_entry_move_down(smentry->entry); 707 711 if (rc != EOK) 708 712 return; … … 711 715 712 716 (void)ui_control_paint(ui_list_ctl(smenu->entries_list)); 717 (void)tbarcfg_notify(TBARCFG_NOTIFY_DEFAULT); 713 718 } 714 719 -
uspace/app/taskbar/meson.build
re4cc266 r34aad53d 48 48 ) 49 49 50 if install_nonessential_data 51 installed_data += { 'name': 'taskbar.sif', 'dir': '/cfg' } 52 endif 50 installed_data += { 'name': 'taskbar.sif', 'dir': '/cfg' } -
uspace/app/taskbar/taskbar.c
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 48 48 #include "wndlist.h" 49 49 50 #define TASKBAR_CONFIG_FILE "/cfg/taskbar.sif" 51 50 52 static void taskbar_wnd_close(ui_window_t *, void *); 51 53 static void taskbar_wnd_kbd(ui_window_t *, void *, kbd_event_t *); 52 54 static void taskbar_wnd_pos(ui_window_t *, void *, pos_event_t *); 55 static void taskbar_notif_cb(void *); 53 56 54 57 static ui_window_cb_t window_cb = { … … 128 131 gfx_rect_t scr_rect; 129 132 gfx_rect_t rect; 133 char *dspec = NULL; 134 char *qmark; 130 135 errno_t rc; 131 136 132 137 taskbar = calloc(1, sizeof(taskbar_t)); 133 138 if (taskbar == NULL) { 139 printf("Out of memory.\n"); 134 140 rc = ENOMEM; 135 141 goto error; 136 142 } 143 144 dspec = str_dup(display_spec); 145 if (dspec == NULL) { 146 printf("Out of memory.\n"); 147 rc = ENOMEM; 148 goto error; 149 } 150 151 /* Remove additional arguments */ 152 qmark = str_chr(dspec, '?'); 153 if (qmark != NULL) 154 *qmark = '\0'; 137 155 138 156 rc = ui_create(display_spec, &taskbar->ui); … … 195 213 } 196 214 197 rc = tbsmenu_create(taskbar->window, taskbar->fixed, &taskbar->tbsmenu); 215 rc = tbsmenu_create(taskbar->window, taskbar->fixed, dspec, 216 &taskbar->tbsmenu); 198 217 if (rc != EOK) { 199 218 printf("Error creating start menu.\n"); … … 201 220 } 202 221 203 rc = tbsmenu_load(taskbar->tbsmenu, "/cfg/taskbar.sif");222 rc = tbsmenu_load(taskbar->tbsmenu, TASKBAR_CONFIG_FILE); 204 223 if (rc != EOK) { 205 224 printf("Error loading start menu from '%s'.\n", 206 "/cfg/taskbar.sif"); 225 TASKBAR_CONFIG_FILE); 226 } 227 228 rc = tbarcfg_listener_create(TBARCFG_NOTIFY_DEFAULT, 229 taskbar_notif_cb, (void *)taskbar, &taskbar->lst); 230 if (rc != EOK) { 231 printf("Error listening for configuration changes.\n"); 207 232 } 208 233 … … 284 309 } 285 310 311 free(dspec); 286 312 *rtaskbar = taskbar; 287 313 return EOK; 288 314 error: 315 if (dspec != NULL) 316 free(dspec); 317 if (taskbar->lst != NULL) 318 tbarcfg_listener_destroy(taskbar->lst); 289 319 if (taskbar->clock != NULL) 290 320 taskbar_clock_destroy(taskbar->clock); … … 297 327 if (taskbar->ui != NULL) 298 328 ui_destroy(taskbar->ui); 329 free(taskbar); 299 330 return rc; 300 331 … … 304 335 void taskbar_destroy(taskbar_t *taskbar) 305 336 { 337 if (taskbar->lst != NULL) 338 tbarcfg_listener_destroy(taskbar->lst); 306 339 ui_fixed_remove(taskbar->fixed, taskbar_clock_ctl(taskbar->clock)); 307 340 taskbar_clock_destroy(taskbar->clock); … … 312 345 } 313 346 347 /** Configuration change notification callback. 348 * 349 * Called when configuration changed. 350 * 351 * @param arg Argument (taskbar_t *) 352 */ 353 static void taskbar_notif_cb(void *arg) 354 { 355 taskbar_t *taskbar = (taskbar_t *)arg; 356 357 ui_lock(taskbar->ui); 358 tbsmenu_reload(taskbar->tbsmenu); 359 ui_unlock(taskbar->ui); 360 } 361 314 362 /** @} 315 363 */ -
uspace/app/taskbar/taskbar.sif
re4cc266 r34aad53d 1 [sif](){[entries](){[entry]([caption]=[~N~avigator][cmd]=[/app/nav][terminal]=[y]){}[entry]([caption]=[Text ~E~ditor][cmd]=[/app/edit][terminal]=[y]){}[entry]([caption]=[Co~m~mand Line][cmd]=[/app/bdsh][terminal]=[y]){}[entry]([caption]=[~C~alculator][cmd]=[/app/calculator ][terminal]=[n]){}[entry]([separator]=[y]){}[entry]([caption]=[~U~I Demo][cmd]=[/app/uidemo][terminal]=[n]){}[entry]([caption]=[~G~FX Demo][cmd]=[/app/gfxdemo ui][terminal]=[n]){}[entry]([caption]=[~B~arber Pole][cmd]=[/app/barber][terminal]=[n]){}[entry]([caption]=[~T~etris][cmd]=[/app/tetris][terminal]=[y]){}[entry]([separator]=[y]){}[entry]([caption]=[~D~isplay Configuration][cmd]=[/app/display-cfg][terminal]=[n]){}[entry]([caption]=[Ta~s~kbar Configuration][cmd]=[/app/taskbar-cfg][terminal]=[n]){}[entry]([separator]=[y]){}[entry]([caption]=[Tas~k~ Monitor (top)][cmd]=[/app/top][terminal]=[y]){}[entry]([caption]=[~F~disk Disk Editor][cmd]=[/app/fdisk][terminal]=[y]){}}}1 [sif](){[entries](){[entry]([caption]=[~N~avigator][cmd]=[/app/nav][terminal]=[y]){}[entry]([caption]=[Text ~E~ditor][cmd]=[/app/edit][terminal]=[y]){}[entry]([caption]=[Co~m~mand Line][cmd]=[/app/bdsh][terminal]=[y]){}[entry]([caption]=[~C~alculator][cmd]=[/app/calculator -d %d][terminal]=[n]){}[entry]([caption]=[~I~mage Viewer][cmd]=[/app/viewer -d %d][terminal]=[n]){}[entry]([separator]=[y]){}[entry]([caption]=[~U~I Demo][cmd]=[/app/uidemo -d %d][terminal]=[n]){}[entry]([caption]=[~G~FX Demo][cmd]=[/app/gfxdemo -d %d ui][terminal]=[n]){}[entry]([caption]=[~B~arber Pole][cmd]=[/app/barber -d %d][terminal]=[n]){}[entry]([caption]=[~T~etris][cmd]=[/app/tetris][terminal]=[y]){}[entry]([separator]=[y]){}[entry]([caption]=[~D~isplay Configuration][cmd]=[/app/display-cfg -d %d][terminal]=[n]){}[entry]([caption]=[Ta~s~kbar Configuration][cmd]=[/app/taskbar-cfg -d %d][terminal]=[n]){}[entry]([separator]=[y]){}[entry]([caption]=[Tas~k~ Monitor (top)][cmd]=[/app/top][terminal]=[y]){}[entry]([caption]=[~F~disk Disk Editor][cmd]=[/app/fdisk][terminal]=[y]){}[entry]([separator]=[y]){}[entry]([caption]=[~A~bout HelenOS][cmd]=[/app/aboutos -d %d][terminal]=[n]){}}} -
uspace/app/taskbar/tbsmenu.c
re4cc266 r34aad53d 64 64 static void tbsmenu_smenu_entry_cb(ui_menu_entry_t *, void *); 65 65 static errno_t tbsmenu_entry_start(tbsmenu_entry_t *); 66 static void tbsmenu_cmd_fini(tbsmenu_cmd_t *); 66 67 67 68 /** Create taskbar start menu. … … 69 70 * @param window Containing window 70 71 * @param fixed Fixed layout to which start button will be added 72 * @param dspec Display specification (for passing to applications) 71 73 * @param rtbsmenu Place to store pointer to new start menu 72 74 * @return @c EOK on success or an error code 73 75 */ 74 76 errno_t tbsmenu_create(ui_window_t *window, ui_fixed_t *fixed, 75 tbsmenu_t **rtbsmenu)77 const char *dspec, tbsmenu_t **rtbsmenu) 76 78 { 77 79 ui_resource_t *res = ui_window_get_res(window); … … 85 87 } 86 88 89 tbsmenu->display_spec = str_dup(dspec); 90 if (tbsmenu->display_spec == NULL) { 91 rc = ENOMEM; 92 goto error; 93 } 94 87 95 rc = ui_pbutton_create(res, "Start", &tbsmenu->sbutton); 88 96 if (rc != EOK) … … 111 119 return EOK; 112 120 error: 121 if (tbsmenu != NULL && tbsmenu->display_spec != NULL) 122 free(tbsmenu->display_spec); 113 123 if (tbsmenu != NULL) 114 124 ui_pbutton_destroy(tbsmenu->sbutton); … … 134 144 bool terminal; 135 145 errno_t rc; 146 147 if (tbsmenu->repopath != NULL) 148 free(tbsmenu->repopath); 149 150 tbsmenu->repopath = str_dup(repopath); 151 if (tbsmenu->repopath == NULL) 152 return ENOMEM; 153 154 /* Remove existing entries */ 155 tentry = tbsmenu_first(tbsmenu); 156 while (tentry != NULL) { 157 tbsmenu_remove(tbsmenu, tentry, false); 158 tentry = tbsmenu_first(tbsmenu); 159 } 136 160 137 161 rc = tbarcfg_open(repopath, &tbcfg); … … 170 194 } 171 195 196 /** Reload start menu from repository (or schedule reload). 197 * 198 * @param tbsmenu Start menu 199 */ 200 void tbsmenu_reload(tbsmenu_t *tbsmenu) 201 { 202 if (!tbsmenu_is_open(tbsmenu)) 203 (void) tbsmenu_load(tbsmenu, tbsmenu->repopath); 204 else 205 tbsmenu->needs_reload = true; 206 } 207 172 208 /** Set start menu rectangle. 173 209 * … … 198 234 { 199 235 ui_menu_close(tbsmenu->smenu); 236 237 if (tbsmenu->needs_reload) 238 (void) tbsmenu_load(tbsmenu, tbsmenu->repopath); 200 239 } 201 240 … … 447 486 static errno_t tbsmenu_cmd_split(const char *str, tbsmenu_cmd_t *cmd) 448 487 { 488 char *buf; 449 489 char *arg; 450 490 char *next; 451 491 size_t cnt; 452 492 453 cmd->buf = str_dup(str);454 if ( cmd->buf == NULL)493 buf = str_dup(str); 494 if (buf == NULL) 455 495 return ENOMEM; 456 496 457 497 /* Count the entries */ 458 498 cnt = 0; 459 arg = str_tok( cmd->buf, " ", &next);499 arg = str_tok(buf, " ", &next); 460 500 while (arg != NULL) { 461 501 ++cnt; … … 464 504 465 505 /* Need to copy again as buf was mangled */ 466 free( cmd->buf);467 cmd->buf = str_dup(str);468 if ( cmd->buf == NULL)506 free(buf); 507 buf = str_dup(str); 508 if (buf == NULL) 469 509 return ENOMEM; 470 510 471 511 cmd->argv = calloc(cnt + 1, sizeof(char *)); 472 512 if (cmd->argv == NULL) { 473 free( cmd->buf);513 free(buf); 474 514 return ENOMEM; 475 515 } 476 516 477 /* Fill in pointers */517 /* Copy individual arguments */ 478 518 cnt = 0; 479 arg = str_tok( cmd->buf, " ", &next);519 arg = str_tok(buf, " ", &next); 480 520 while (arg != NULL) { 481 cmd->argv[cnt++] = arg; 521 cmd->argv[cnt] = str_dup(arg); 522 if (cmd->argv[cnt] == NULL) { 523 tbsmenu_cmd_fini(cmd); 524 return ENOMEM; 525 } 526 ++cnt; 527 482 528 arg = str_tok(next, " ", &next); 483 529 } … … 494 540 static void tbsmenu_cmd_fini(tbsmenu_cmd_t *cmd) 495 541 { 542 char **cp; 543 544 /* Free all pointers in NULL-terminated list */ 545 cp = cmd->argv; 546 while (*cp != NULL) { 547 free(*cp); 548 ++cp; 549 } 550 551 /* Free the array of pointers */ 496 552 free(cmd->argv); 497 free(cmd->buf); 553 } 554 555 /** Free command structure. 556 * 557 * @param cmd Command 558 * @param entry Start menu entry 559 * @param dspec Display specification 560 * @return EOK on success or an error code 561 */ 562 static errno_t tbsmenu_cmd_subst(tbsmenu_cmd_t *cmd, tbsmenu_entry_t *entry, 563 const char *dspec) 564 { 565 char **cp; 566 567 (void)entry; 568 569 /* Walk NULL-terminated list of arguments */ 570 cp = cmd->argv; 571 while (*cp != NULL) { 572 if (str_cmp(*cp, "%d") == 0) { 573 /* Display specification */ 574 free(*cp); 575 *cp = str_dup(dspec); 576 if (*cp == NULL) 577 return ENOMEM; 578 } 579 ++cp; 580 } 581 582 return EOK; 498 583 } 499 584 … … 516 601 char **cp; 517 602 const char **targv = NULL; 603 char *dspec = NULL; 604 sysarg_t idev_id; 605 int rv; 518 606 errno_t rc; 519 607 ui_t *ui; … … 522 610 suspended = false; 523 611 612 idev_id = ui_menu_get_idev_id(entry->tbsmenu->smenu); 613 614 rv = asprintf(&dspec, "%s?idev=%zu", 615 entry->tbsmenu->display_spec, (size_t)idev_id); 616 if (rv < 0) 617 return ENOMEM; 618 619 /* Split command string into individual arguments */ 524 620 rc = tbsmenu_cmd_split(entry->cmd, &cmd); 525 if (rc != EOK) 621 if (rc != EOK) { 622 free(dspec); 526 623 return rc; 624 } 625 626 /* Substitute metacharacters in command */ 627 rc = tbsmenu_cmd_subst(&cmd, entry, dspec); 628 if (rc != EOK) 629 goto error; 527 630 528 631 /* Free up and clean console for the child task. */ … … 542 645 } 543 646 544 targv = calloc(cnt + 3, sizeof(char **));647 targv = calloc(cnt + 5, sizeof(char **)); 545 648 if (targv == NULL) 546 649 goto error; 547 650 548 651 targv[0] = "/app/terminal"; 549 targv[1] = "-c"; 652 targv[1] = "-d"; 653 targv[2] = dspec; 654 targv[3] = "-c"; 550 655 551 656 for (i = 0; i <= cnt; i++) { 552 targv[ 2+ i] = cmd.argv[i];657 targv[4 + i] = cmd.argv[i]; 553 658 } 554 659 … … 578 683 return EOK; 579 684 error: 685 free(dspec); 580 686 if (targv != NULL) 581 687 free(targv); -
uspace/app/taskbar/tbsmenu.h
re4cc266 r34aad53d 46 46 #include "types/tbsmenu.h" 47 47 48 extern errno_t tbsmenu_create(ui_window_t *, ui_fixed_t *, tbsmenu_t **); 48 extern errno_t tbsmenu_create(ui_window_t *, ui_fixed_t *, const char *, 49 tbsmenu_t **); 49 50 extern errno_t tbsmenu_load(tbsmenu_t *, const char *); 51 extern void tbsmenu_reload(tbsmenu_t *); 50 52 extern void tbsmenu_set_rect(tbsmenu_t *, gfx_rect_t *); 51 53 extern void tbsmenu_open(tbsmenu_t *); -
uspace/app/taskbar/test/tbsmenu.c
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 61 61 ui_window_add(window, ui_fixed_ctl(fixed)); 62 62 63 rc = tbsmenu_create(window, fixed, &tbsmenu);63 rc = tbsmenu_create(window, fixed, UI_DISPLAY_DEFAULT, &tbsmenu); 64 64 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 65 65 … … 92 92 ui_window_add(window, ui_fixed_ctl(fixed)); 93 93 94 rc = tbsmenu_create(window, fixed, &tbsmenu);94 rc = tbsmenu_create(window, fixed, UI_DISPLAY_DEFAULT, &tbsmenu); 95 95 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 96 96 -
uspace/app/taskbar/types/taskbar.h
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 60 60 /** Clock */ 61 61 taskbar_clock_t *clock; 62 /** Configuration change listener */ 63 tbarcfg_listener_t *lst; 62 64 } taskbar_t; 63 65 -
uspace/app/taskbar/types/tbsmenu.h
re4cc266 r34aad53d 40 40 #include <gfx/coord.h> 41 41 #include <stdbool.h> 42 #include <tbarcfg/tbarcfg.h> 42 43 #include <ui/pbutton.h> 43 44 #include <ui/fixed.h> … … 84 85 /** Device ID of last input event */ 85 86 sysarg_t ev_idev_id; 87 88 /** Repository path name */ 89 char *repopath; 90 91 /** Need to reload menu when possible */ 92 bool needs_reload; 93 94 /** Display specification */ 95 char *display_spec; 86 96 } tbsmenu_t; 87 97 88 98 /** Command split into individual parts */ 89 99 typedef struct { 90 /** Buffer holding broken down command */91 char *buf;92 100 /** NULL-terminated array of string pointers */ 93 101 char **argv; -
uspace/app/terminal/terminal.c
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * Copyright (c) 2012 Petr Koupy 4 4 * All rights reserved. … … 974 974 wparams.placement = ui_wnd_place_top_left; 975 975 976 rc = ui_create(display_spec, &term->ui); 977 if (rc != EOK) { 978 printf("Error creating UI on %s.\n", display_spec); 979 goto error; 980 } 981 976 982 /* 977 983 * Compute window rectangle such that application area corresponds 978 984 * to rect 979 985 */ 980 ui_wdecor_rect_from_app( wparams.style, &rect, &wrect);986 ui_wdecor_rect_from_app(term->ui, wparams.style, &rect, &wrect); 981 987 off = wrect.p0; 982 988 gfx_rect_rtranslate(&off, &wrect, &wparams.rect); 983 989 984 990 term->off = off; 985 986 rc = ui_create(display_spec, &term->ui);987 if (rc != EOK) {988 printf("Error creating UI on %s.\n", display_spec);989 goto error;990 }991 991 992 992 rc = ui_window_create(term->ui, &wparams, &term->window); -
uspace/app/viewer/viewer.c
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * Copyright (c) 2013 Martin Decky 4 4 * All rights reserved. … … 40 40 #include <stdlib.h> 41 41 #include <str.h> 42 #include <ui/filedialog.h> 42 43 #include <ui/image.h> 43 44 #include <ui/ui.h> … … 50 51 typedef struct { 51 52 ui_t *ui; 53 54 size_t imgs_count; 55 size_t imgs_current; 56 char **imgs; 57 58 bool fullscreen; 59 ui_window_t *window; 60 gfx_bitmap_t *bitmap; 61 ui_image_t *image; 62 gfx_context_t *window_gc; 63 ui_file_dialog_t *dialog; 64 65 gfx_rect_t img_rect; 52 66 } viewer_t; 53 67 54 static size_t imgs_count; 55 static size_t imgs_current = 0; 56 static char **imgs; 57 58 static ui_window_t *window; 59 static gfx_bitmap_t *bitmap = NULL; 60 static ui_image_t *image = NULL; 61 static gfx_context_t *window_gc; 62 63 static gfx_rect_t img_rect; 64 65 static bool img_load(gfx_context_t *gc, const char *, gfx_bitmap_t **, 68 static bool viewer_img_load(viewer_t *, const char *, gfx_bitmap_t **, 66 69 gfx_rect_t *); 67 static bool img_setup(gfx_context_t *, gfx_bitmap_t *, gfx_rect_t *); 70 static bool viewer_img_setup(viewer_t *, gfx_bitmap_t *, gfx_rect_t *); 71 static errno_t viewer_window_create(viewer_t *); 72 static void viewer_window_destroy(viewer_t *); 68 73 69 74 static void wnd_close(ui_window_t *, void *); … … 75 80 }; 76 81 82 static void file_dialog_bok(ui_file_dialog_t *, void *, const char *); 83 static void file_dialog_bcancel(ui_file_dialog_t *, void *); 84 static void file_dialog_close(ui_file_dialog_t *, void *); 85 86 static ui_file_dialog_cb_t file_dialog_cb = { 87 .bok = file_dialog_bok, 88 .bcancel = file_dialog_bcancel, 89 .close = file_dialog_close 90 }; 91 77 92 /** Window close request 78 93 * … … 87 102 } 88 103 89 static void wnd_kbd_event(ui_window_t *window, void *arg, 90 kbd_event_t *event) 104 /** Viewer unmodified key press. 105 * 106 * @param viewer Viewer 107 * @param event Keyboard event 108 */ 109 static void viewer_kbd_event_unmod(viewer_t *viewer, kbd_event_t *event) 91 110 { 92 111 bool update = false; 93 112 94 if ( (event->type == KEY_PRESS) && (event->c == 'q'))95 exit(0);96 97 if ( (event->type == KEY_PRESS) && (event->key == KC_PAGE_DOWN)) {98 if ( imgs_current ==imgs_count - 1)99 imgs_current = 0;113 if (event->key == KC_Q || event->key == KC_ESCAPE) 114 ui_quit(viewer->ui); 115 116 if (event->key == KC_PAGE_DOWN) { 117 if (viewer->imgs_current == viewer->imgs_count - 1) 118 viewer->imgs_current = 0; 100 119 else 101 imgs_current++;120 viewer->imgs_current++; 102 121 103 122 update = true; 104 123 } 105 124 106 if ( (event->type == KEY_PRESS) && (event->key == KC_PAGE_UP)) {107 if ( imgs_current == 0)108 imgs_current =imgs_count - 1;125 if (event->key == KC_PAGE_UP) { 126 if (viewer->imgs_current == 0) 127 viewer->imgs_current = viewer->imgs_count - 1; 109 128 else 110 imgs_current--;129 viewer->imgs_current--; 111 130 112 131 update = true; … … 117 136 gfx_rect_t lrect; 118 137 119 if (!img_load(window_gc, imgs[imgs_current], &lbitmap, &lrect)) { 120 printf("Cannot load image \"%s\".\n", imgs[imgs_current]); 138 if (!viewer_img_load(viewer, viewer->imgs[viewer->imgs_current], 139 &lbitmap, &lrect)) { 140 printf("Cannot load image \"%s\".\n", 141 viewer->imgs[viewer->imgs_current]); 121 142 exit(4); 122 143 } 123 if (!img_setup(window_gc, lbitmap, &lrect)) { 124 printf("Cannot setup image \"%s\".\n", imgs[imgs_current]); 144 if (!viewer_img_setup(viewer, lbitmap, &lrect)) { 145 printf("Cannot setup image \"%s\".\n", 146 viewer->imgs[viewer->imgs_current]); 125 147 exit(6); 126 148 } … … 128 150 } 129 151 130 static bool img_load(gfx_context_t *gc, const char *fname, 152 /** Viewer ctrl-key key press. 153 * 154 * @param viewer Viewer 155 * @param event Keyboard event 156 */ 157 static void viewer_kbd_event_ctrl(viewer_t *viewer, kbd_event_t *event) 158 { 159 if (event->key == KC_Q) 160 ui_quit(viewer->ui); 161 } 162 163 /** Viewer window keyboard event. 164 * 165 * @param window UI window 166 * @param arg Argument (viewer_t *) 167 * @param event Keyboard event 168 */ 169 static void wnd_kbd_event(ui_window_t *window, void *arg, 170 kbd_event_t *event) 171 { 172 viewer_t *viewer = (viewer_t *)arg; 173 174 if (event->type != KEY_PRESS) 175 return; 176 177 if ((event->mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) 178 viewer_kbd_event_unmod(viewer, event); 179 180 if ((event->mods & KM_CTRL) != 0 && 181 (event->mods & (KM_ALT | KM_SHIFT)) == 0) 182 viewer_kbd_event_ctrl(viewer, event); 183 184 ui_window_def_kbd(window, event); 185 } 186 187 /** File dialog OK button press. 188 * 189 * @param dialog File dialog 190 * @param arg Argument (viewer_t *) 191 * @param fname File name 192 */ 193 static void file_dialog_bok(ui_file_dialog_t *dialog, void *arg, 194 const char *fname) 195 { 196 viewer_t *viewer = (viewer_t *) arg; 197 errno_t rc; 198 199 viewer->imgs_count = 1; 200 viewer->imgs = calloc(viewer->imgs_count, sizeof(char *)); 201 if (viewer->imgs == NULL) { 202 printf("Out of memory.\n"); 203 ui_quit(viewer->ui); 204 return; 205 } 206 207 viewer->imgs[0] = str_dup(fname); 208 if (viewer->imgs[0] == NULL) { 209 printf("Out of memory.\n"); 210 ui_quit(viewer->ui); 211 return; 212 } 213 214 rc = viewer_window_create(viewer); 215 if (rc != EOK) 216 ui_quit(viewer->ui); 217 218 ui_file_dialog_destroy(dialog); 219 viewer->dialog = NULL; 220 } 221 222 /** File dialog cancel button press. 223 * 224 * @param dialog File dialog 225 * @param arg Argument (viewer_t *) 226 */ 227 static void file_dialog_bcancel(ui_file_dialog_t *dialog, void *arg) 228 { 229 viewer_t *viewer = (viewer_t *) arg; 230 231 ui_file_dialog_destroy(dialog); 232 ui_quit(viewer->ui); 233 } 234 235 /** File dialog close request. 236 * 237 * @param dialog File dialog 238 * @param arg Argument (viewer_t *) 239 */ 240 static void file_dialog_close(ui_file_dialog_t *dialog, void *arg) 241 { 242 viewer_t *viewer = (viewer_t *) arg; 243 244 ui_file_dialog_destroy(dialog); 245 ui_quit(viewer->ui); 246 } 247 248 static bool viewer_img_load(viewer_t *viewer, const char *fname, 131 249 gfx_bitmap_t **rbitmap, gfx_rect_t *rect) 132 250 { … … 159 277 vfs_put(fd); 160 278 161 rc = decode_tga( gc, tga, stat.size, rbitmap, rect);279 rc = decode_tga(viewer->window_gc, tga, stat.size, rbitmap, rect); 162 280 if (rc != EOK) { 163 281 free(tga); … … 167 285 free(tga); 168 286 169 img_rect = *rect;287 viewer->img_rect = *rect; 170 288 return true; 171 289 } 172 290 173 static bool img_setup(gfx_context_t *gc, gfx_bitmap_t *bmp, gfx_rect_t *rect) 291 static bool viewer_img_setup(viewer_t *viewer, gfx_bitmap_t *bmp, 292 gfx_rect_t *rect) 174 293 { 175 294 gfx_rect_t arect; … … 178 297 errno_t rc; 179 298 180 ui_res = ui_window_get_res( window);181 182 ui_window_get_app_rect( window, &arect);299 ui_res = ui_window_get_res(viewer->window); 300 301 ui_window_get_app_rect(viewer->window, &arect); 183 302 184 303 /* Center image on application area */ 185 304 gfx_rect_ctr_on_rect(rect, &arect, &irect); 186 305 187 if ( image != NULL) {188 ui_image_set_bmp( image, bmp, rect);189 (void) ui_image_paint( image);190 ui_image_set_rect( image, &irect);306 if (viewer->image != NULL) { 307 ui_image_set_bmp(viewer->image, bmp, rect); 308 (void) ui_image_paint(viewer->image); 309 ui_image_set_rect(viewer->image, &irect); 191 310 } else { 192 rc = ui_image_create(ui_res, bmp, rect, & image);311 rc = ui_image_create(ui_res, bmp, rect, &viewer->image); 193 312 if (rc != EOK) { 194 313 gfx_bitmap_destroy(bmp); … … 196 315 } 197 316 198 ui_image_set_rect( image, &irect);199 ui_window_add( window, ui_image_ctl(image));200 } 201 202 if ( bitmap != NULL)203 gfx_bitmap_destroy( bitmap);204 205 bitmap = bmp;317 ui_image_set_rect(viewer->image, &irect); 318 ui_window_add(viewer->window, ui_image_ctl(viewer->image)); 319 } 320 321 if (viewer->bitmap != NULL) 322 gfx_bitmap_destroy(viewer->bitmap); 323 324 viewer->bitmap = bmp; 206 325 return true; 207 326 } … … 214 333 } 215 334 216 int main(int argc, char *argv[])217 { 218 const char *display_spec = UI_DISPLAY_DEFAULT;335 static errno_t viewer_window_create(viewer_t *viewer) 336 { 337 ui_wnd_params_t params; 219 338 gfx_bitmap_t *lbitmap; 220 339 gfx_rect_t lrect; 221 bool fullscreen = false;222 gfx_rect_t rect;223 340 gfx_rect_t wrect; 224 341 gfx_coord2_t off; 225 ui_t *ui; 226 ui_wnd_params_t params; 227 viewer_t viewer; 342 gfx_rect_t rect; 228 343 errno_t rc; 229 int i;230 231 i = 1;232 while (i < argc && argv[i][0] == '-') {233 if (str_cmp(argv[i], "-d") == 0) {234 ++i;235 if (i >= argc) {236 printf("Argument missing.\n");237 print_syntax();238 return 1;239 }240 241 display_spec = argv[i++];242 } else if (str_cmp(argv[i], "-f") == 0) {243 ++i;244 fullscreen = true;245 } else {246 printf("Invalid option '%s'.\n", argv[i]);247 print_syntax();248 return 1;249 }250 }251 252 if (i >= argc) {253 printf("No image files specified.\n");254 print_syntax();255 return 1;256 }257 258 imgs_count = argc - i;259 imgs = calloc(imgs_count, sizeof(char *));260 if (imgs == NULL) {261 printf("Out of memory.\n");262 return 1;263 }264 265 for (int j = 0; j < argc - i; j++) {266 imgs[j] = str_dup(argv[i + j]);267 if (imgs[j] == NULL) {268 printf("Out of memory.\n");269 return 3;270 }271 }272 273 rc = ui_create(display_spec, &ui);274 if (rc != EOK) {275 printf("Error creating UI on display %s.\n", display_spec);276 return 1;277 }278 279 viewer.ui = ui;280 344 281 345 /* … … 290 354 params.rect.p1.y = 1; 291 355 292 if ( fullscreen) {356 if (viewer->fullscreen) { 293 357 params.style &= ~ui_wds_decorated; 294 358 params.placement = ui_wnd_place_full_screen; 295 359 } 296 360 297 rc = ui_window_create( ui, ¶ms, &window);361 rc = ui_window_create(viewer->ui, ¶ms, &viewer->window); 298 362 if (rc != EOK) { 299 363 printf("Error creating window.\n"); 300 return 1; 301 } 302 303 window_gc = ui_window_get_gc(window); 304 305 ui_window_set_cb(window, &window_cb, (void *) &viewer); 306 307 if (!img_load(window_gc, imgs[imgs_current], &lbitmap, &lrect)) { 308 printf("Cannot load image \"%s\".\n", imgs[imgs_current]); 309 return 1; 364 goto error; 365 } 366 367 viewer->window_gc = ui_window_get_gc(viewer->window); 368 369 ui_window_set_cb(viewer->window, &window_cb, (void *)viewer); 370 371 if (!viewer_img_load(viewer, viewer->imgs[viewer->imgs_current], 372 &lbitmap, &lrect)) { 373 printf("Cannot load image \"%s\".\n", 374 viewer->imgs[viewer->imgs_current]); 375 goto error; 310 376 } 311 377 … … 314 380 * to rect 315 381 */ 316 ui_wdecor_rect_from_app( params.style, &lrect, &wrect);382 ui_wdecor_rect_from_app(viewer->ui, params.style, &lrect, &wrect); 317 383 off = wrect.p0; 318 384 gfx_rect_rtranslate(&off, &wrect, &rect); 319 385 320 if (! fullscreen) {321 rc = ui_window_resize( window, &rect);386 if (!viewer->fullscreen) { 387 rc = ui_window_resize(viewer->window, &rect); 322 388 if (rc != EOK) { 323 389 printf("Error resizing window.\n"); 324 return 1; 325 } 326 } 327 328 if (!img_setup(window_gc, lbitmap, &lrect)) { 329 printf("Cannot setup image \"%s\".\n", imgs[imgs_current]); 330 return 1; 331 } 332 333 rc = ui_window_paint(window); 390 goto error; 391 } 392 } 393 394 if (!viewer_img_setup(viewer, lbitmap, &lrect)) { 395 printf("Cannot setup image \"%s\".\n", 396 viewer->imgs[viewer->imgs_current]); 397 goto error; 398 } 399 400 rc = ui_window_paint(viewer->window); 334 401 if (rc != EOK) { 335 402 printf("Error painting window.\n"); 336 return 1; 403 goto error; 404 } 405 406 return EOK; 407 error: 408 viewer_window_destroy(viewer); 409 ui_quit(viewer->ui); 410 return rc; 411 } 412 413 static void viewer_window_destroy(viewer_t *viewer) 414 { 415 if (viewer->window != NULL) 416 ui_window_destroy(viewer->window); 417 viewer->window = NULL; 418 } 419 420 int main(int argc, char *argv[]) 421 { 422 const char *display_spec = UI_ANY_DEFAULT; 423 ui_t *ui = NULL; 424 viewer_t *viewer; 425 errno_t rc; 426 int i; 427 unsigned u; 428 ui_file_dialog_params_t fdparams; 429 430 viewer = calloc(1, sizeof(viewer_t)); 431 if (viewer == NULL) { 432 printf("Out of memory.\n"); 433 goto error; 434 } 435 436 i = 1; 437 while (i < argc && argv[i][0] == '-') { 438 if (str_cmp(argv[i], "-d") == 0) { 439 ++i; 440 if (i >= argc) { 441 printf("Argument missing.\n"); 442 print_syntax(); 443 goto error; 444 } 445 446 display_spec = argv[i++]; 447 } else if (str_cmp(argv[i], "-f") == 0) { 448 ++i; 449 viewer->fullscreen = true; 450 } else { 451 printf("Invalid option '%s'.\n", argv[i]); 452 print_syntax(); 453 goto error; 454 } 455 } 456 457 /* Images specified? */ 458 if (i < argc) { 459 viewer->imgs_count = argc - i; 460 viewer->imgs = calloc(viewer->imgs_count, sizeof(char *)); 461 if (viewer->imgs == NULL) { 462 printf("Out of memory.\n"); 463 goto error; 464 } 465 466 for (int j = 0; j < argc - i; j++) { 467 viewer->imgs[j] = str_dup(argv[i + j]); 468 if (viewer->imgs[j] == NULL) { 469 printf("Out of memory.\n"); 470 goto error; 471 } 472 } 473 } 474 475 rc = ui_create(display_spec, &ui); 476 if (rc != EOK) { 477 printf("Error creating UI on display %s.\n", display_spec); 478 goto error; 479 } 480 481 if (ui_is_fullscreen(ui)) 482 viewer->fullscreen = true; 483 484 viewer->ui = ui; 485 486 if (viewer->imgs != NULL) { 487 /* We have images, create viewer window. */ 488 rc = viewer_window_create(viewer); 489 if (rc != EOK) 490 goto error; 491 } else { 492 /* No images specified, browse for one. */ 493 ui_file_dialog_params_init(&fdparams); 494 fdparams.caption = "Open Image"; 495 496 rc = ui_file_dialog_create(viewer->ui, &fdparams, 497 &viewer->dialog); 498 if (rc != EOK) { 499 printf("Error creating file dialog.\n"); 500 goto error; 501 } 502 503 ui_file_dialog_set_cb(viewer->dialog, &file_dialog_cb, 504 (void *)viewer); 337 505 } 338 506 339 507 ui_run(ui); 340 508 509 ui_window_destroy(viewer->window); 510 ui_destroy(ui); 511 free(viewer); 512 341 513 return 0; 514 error: 515 if (viewer != NULL && viewer->dialog != NULL) 516 ui_file_dialog_destroy(viewer->dialog); 517 if (viewer != NULL && viewer->imgs != NULL) { 518 for (u = 0; u < viewer->imgs_count; u++) { 519 if (viewer->imgs[i] != NULL) 520 free(viewer->imgs[i]); 521 } 522 free(viewer->imgs); 523 } 524 if (viewer != NULL) 525 viewer_window_destroy(viewer); 526 if (ui != NULL) 527 ui_destroy(ui); 528 if (viewer != NULL) 529 free(viewer); 530 return 1; 342 531 } 343 532 -
uspace/lib/congfx/src/console.c
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 91 91 uint8_t attr; 92 92 93 if ((clr >> 24) == 0 ) {93 if ((clr >> 24) == 0xff) { 94 94 /* RGB (no text) */ 95 95 ch->ch = 0; 96 96 ch->flags = CHAR_FLAG_DIRTY; 97 97 ch->attrs.type = CHAR_ATTR_RGB; 98 ch->attrs.val.rgb.fgcolor = clr ^ 0xffffff;98 ch->attrs.val.rgb.fgcolor = clr; 99 99 ch->attrs.val.rgb.bgcolor = clr; 100 100 } else { -
uspace/lib/gfx/src/color.c
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 64 64 color->g = g; 65 65 color->b = b; 66 color->attr = 0xff; 66 67 67 68 *rcolor = color; -
uspace/lib/meson.build
re4cc266 r34aad53d 33 33 'c', 34 34 'math', 35 'console', 35 36 'display', 37 'input', 38 'output', 36 39 'pixconv', 37 40 'posix', -
uspace/lib/tbarcfg/include/tbarcfg/tbarcfg.h
re4cc266 r34aad53d 42 42 #include <types/tbarcfg/tbarcfg.h> 43 43 44 #define TBARCFG_NOTIFY_DEFAULT "tbarcfg-notif" 45 44 46 extern errno_t tbarcfg_create(const char *, tbarcfg_t **); 45 47 extern errno_t tbarcfg_open(const char *, tbarcfg_t **); … … 63 65 extern errno_t smenu_entry_move_up(smenu_entry_t *); 64 66 extern errno_t smenu_entry_move_down(smenu_entry_t *); 67 extern errno_t tbarcfg_listener_create(const char *, void (*)(void *), 68 void *, tbarcfg_listener_t **); 69 extern void tbarcfg_listener_destroy(tbarcfg_listener_t *); 70 extern errno_t tbarcfg_notify(const char *); 65 71 66 72 #endif -
uspace/lib/tbarcfg/include/types/tbarcfg/tbarcfg.h
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 43 43 typedef struct smenu_entry smenu_entry_t; 44 44 45 struct tbarcfg_listener; 46 typedef struct tbarcfg_listener tbarcfg_listener_t; 47 45 48 #endif 46 49 -
uspace/lib/tbarcfg/private/tbarcfg.h
re4cc266 r34aad53d 71 71 }; 72 72 73 /** Taskbar configuration listener */ 74 typedef struct tbarcfg_listener { 75 /** Notification callback */ 76 void (*cb)(void *); 77 /** Callback argument */ 78 void *arg; 79 } tbarcfg_listener_t; 80 73 81 extern errno_t smenu_entry_new(tbarcfg_t *, sif_node_t *, const char *, 74 82 const char *, bool, smenu_entry_t **); -
uspace/lib/tbarcfg/src/tbarcfg.c
re4cc266 r34aad53d 34 34 */ 35 35 36 #include <async.h> 36 37 #include <errno.h> 37 38 #include <sif.h> 39 #include <ipc/tbarcfg.h> 40 #include <loc.h> 41 #include <task.h> 38 42 #include <tbarcfg/tbarcfg.h> 43 #include <stdio.h> 39 44 #include <stdlib.h> 40 45 #include <str.h> 41 46 #include "../private/tbarcfg.h" 47 48 static void tbarcfg_notify_conn(ipc_call_t *, void *); 42 49 43 50 /** Create taskbar configuration. … … 784 791 } 785 792 793 /** Create taskbar configuration listener. 794 * 795 * Listens for taskbar configuration change notifications. 796 * 797 * @param nchan Notification channel (TBARCFG_NOTIFY_DEFAULT) 798 * @param rlst Place to store pointer to new listener 799 * @return EOK on success or an error code 800 */ 801 errno_t tbarcfg_listener_create(const char *nchan, void (*cb)(void *), 802 void *arg, tbarcfg_listener_t **rlst) 803 { 804 tbarcfg_listener_t *lst; 805 service_id_t svcid = 0; 806 loc_srv_t *srv = NULL; 807 task_id_t taskid; 808 char *svcname = NULL; 809 category_id_t catid; 810 port_id_t port; 811 int rv; 812 errno_t rc; 813 814 lst = calloc(1, sizeof(tbarcfg_listener_t)); 815 if (lst == NULL) 816 return ENOMEM; 817 818 lst->cb = cb; 819 lst->arg = arg; 820 821 rc = async_create_port(INTERFACE_TBARCFG_NOTIFY, 822 tbarcfg_notify_conn, (void *)lst, &port); 823 if (rc != EOK) 824 goto error; 825 826 rc = loc_server_register("tbarcfg-listener", &srv); 827 if (rc != EOK) 828 goto error; 829 830 taskid = task_get_id(); 831 832 rv = asprintf(&svcname, "tbarcfg/%u", (unsigned)taskid); 833 if (rv < 0) { 834 rc = ENOMEM; 835 goto error; 836 } 837 838 rc = loc_service_register(srv, svcname, &svcid); 839 if (rc != EOK) 840 goto error; 841 842 rc = loc_category_get_id(nchan, &catid, 0); 843 if (rc != EOK) 844 goto error; 845 846 rc = loc_service_add_to_cat(srv, svcid, catid); 847 if (rc != EOK) 848 goto error; 849 850 *rlst = lst; 851 return EOK; 852 error: 853 if (svcid != 0) 854 loc_service_unregister(srv, svcid); 855 if (srv != NULL) 856 loc_server_unregister(srv); 857 if (svcname != NULL) 858 free(svcname); 859 return rc; 860 } 861 862 /** Destroy taskbar configuration listener. 863 * 864 * @param lst Listener 865 */ 866 void tbarcfg_listener_destroy(tbarcfg_listener_t *lst) 867 { 868 free(lst); 869 } 870 871 /** Send taskbar configuration notification to a particular service ID. 872 * 873 * @param svcid Service ID 874 * @return EOK on success or an error code 875 */ 876 static errno_t tbarcfg_notify_svc(service_id_t svcid) 877 { 878 async_sess_t *sess; 879 async_exch_t *exch; 880 errno_t rc; 881 882 sess = loc_service_connect(svcid, INTERFACE_TBARCFG_NOTIFY, 0); 883 if (sess == NULL) 884 return EIO; 885 886 exch = async_exchange_begin(sess); 887 rc = async_req_0_0(exch, TBARCFG_NOTIFY_NOTIFY); 888 if (rc != EOK) { 889 async_exchange_end(exch); 890 async_hangup(sess); 891 return rc; 892 } 893 894 async_exchange_end(exch); 895 async_hangup(sess); 896 return EOK; 897 } 898 899 /** Send taskbar configuration change notification. 900 * 901 * @param nchan Notification channel (TBARCFG_NOTIFY_DEFAULT) 902 */ 903 errno_t tbarcfg_notify(const char *nchan) 904 { 905 errno_t rc; 906 category_id_t catid; 907 service_id_t *svcs = NULL; 908 size_t count, i; 909 910 rc = loc_category_get_id(nchan, &catid, 0); 911 if (rc != EOK) 912 return rc; 913 914 rc = loc_category_get_svcs(catid, &svcs, &count); 915 if (rc != EOK) 916 return rc; 917 918 for (i = 0; i < count; i++) { 919 rc = tbarcfg_notify_svc(svcs[i]); 920 if (rc != EOK) 921 goto error; 922 } 923 924 free(svcs); 925 return EOK; 926 error: 927 free(svcs); 928 return rc; 929 } 930 931 /** Taskbar configuration connection handler. 932 * 933 * @param icall Initial call 934 * @param arg Argument (tbarcfg_listener_t *) 935 */ 936 static void tbarcfg_notify_conn(ipc_call_t *icall, void *arg) 937 { 938 tbarcfg_listener_t *lst = (tbarcfg_listener_t *)arg; 939 940 /* Accept the connection */ 941 async_accept_0(icall); 942 943 while (true) { 944 ipc_call_t call; 945 async_get_call(&call); 946 sysarg_t method = ipc_get_imethod(&call); 947 948 if (!method) { 949 /* The other side has hung up */ 950 async_answer_0(&call, EOK); 951 return; 952 } 953 954 switch (method) { 955 case TBARCFG_NOTIFY_NOTIFY: 956 lst->cb(lst->arg); 957 async_answer_0(&call, EOK); 958 break; 959 default: 960 async_answer_0(&call, EINVAL); 961 } 962 } 963 } 964 786 965 /** @} 787 966 */ -
uspace/lib/tbarcfg/test/tbarcfg.c
re4cc266 r34aad53d 30 30 #include <pcut/pcut.h> 31 31 #include <tbarcfg/tbarcfg.h> 32 #include <stdbool.h> 32 33 #include <stdio.h> 33 34 … … 35 36 36 37 PCUT_TEST_SUITE(tbarcfg); 38 39 typedef struct { 40 bool notified; 41 } tbarcfg_test_resp_t; 42 43 static void test_cb(void *); 37 44 38 45 /** Creating, opening and closing taskbar configuration */ … … 554 561 } 555 562 563 /** Notifications can be delivered from tbarcfg_notify() to a listener. */ 564 PCUT_TEST(notify) 565 { 566 errno_t rc; 567 tbarcfg_listener_t *lst; 568 tbarcfg_test_resp_t test_resp; 569 570 test_resp.notified = false; 571 572 printf("create listener resp=%p\n", (void *)&test_resp); 573 rc = tbarcfg_listener_create(TBARCFG_NOTIFY_DEFAULT, 574 test_cb, &test_resp, &lst); 575 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 576 577 rc = tbarcfg_notify(TBARCFG_NOTIFY_DEFAULT); 578 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 579 580 PCUT_ASSERT_TRUE(test_resp.notified); 581 tbarcfg_listener_destroy(lst); 582 } 583 584 static void test_cb(void *arg) 585 { 586 tbarcfg_test_resp_t *resp = (tbarcfg_test_resp_t *)arg; 587 588 printf("test_cb: executing resp=%p\n", (void *)resp); 589 resp->notified = true; 590 } 591 556 592 PCUT_EXPORT(tbarcfg); -
uspace/lib/ui/include/ui/menu.h
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 59 59 extern ui_evclaim_t ui_menu_pos_event(ui_menu_t *, gfx_coord2_t *, 60 60 pos_event_t *); 61 extern sysarg_t ui_menu_get_idev_id(ui_menu_t *); 61 62 62 63 #endif -
uspace/lib/ui/include/ui/popup.h
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 54 54 extern ui_resource_t *ui_popup_get_res(ui_popup_t *); 55 55 extern gfx_context_t *ui_popup_get_gc(ui_popup_t *); 56 extern sysarg_t ui_popup_get_idev_id(ui_popup_t *); 56 57 57 58 #endif -
uspace/lib/ui/include/ui/wdecor.h
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 44 44 #include <types/ui/event.h> 45 45 #include <types/ui/resource.h> 46 #include <types/ui/ui.h> 46 47 #include <types/ui/wdecor.h> 47 48 … … 58 59 extern ui_evclaim_t ui_wdecor_kbd_event(ui_wdecor_t *, kbd_event_t *); 59 60 extern ui_evclaim_t ui_wdecor_pos_event(ui_wdecor_t *, pos_event_t *); 60 extern void ui_wdecor_rect_from_app(ui_ wdecor_style_t, gfx_rect_t *,61 extern void ui_wdecor_rect_from_app(ui_t *, ui_wdecor_style_t, gfx_rect_t *, 61 62 gfx_rect_t *); 62 63 extern void ui_wdecor_app_from_rect(ui_wdecor_style_t, gfx_rect_t *, -
uspace/lib/ui/private/menu.h
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 70 70 /** Callback argument */ 71 71 void *arg; 72 /** ID of device that activated entry */ 73 sysarg_t idev_id; 72 74 }; 73 75 -
uspace/lib/ui/private/popup.h
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 58 58 /** Placement rectangle */ 59 59 gfx_rect_t place; 60 /** ID of device that sent input event */ 61 sysarg_t idev_id; 60 62 }; 61 63 -
uspace/lib/ui/src/menu.c
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 578 578 ui_menu_t *menu = (ui_menu_t *)arg; 579 579 580 menu->idev_id = ui_popup_get_idev_id(menu->popup); 580 581 ui_menu_kbd_event(menu, event); 581 582 } … … 592 593 gfx_coord2_t spos; 593 594 595 menu->idev_id = ui_popup_get_idev_id(menu->popup); 596 594 597 spos.x = 0; 595 598 spos.y = 0; … … 641 644 } 642 645 646 /** Get ID of last device that input event. 647 * 648 * @param menu Menu 649 * @return Input device ID 650 */ 651 sysarg_t ui_menu_get_idev_id(ui_menu_t *menu) 652 { 653 return menu->idev_id; 654 } 655 643 656 /** @} 644 657 */ -
uspace/lib/ui/src/menuentry.c
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 145 145 return; 146 146 147 mentry->menu->total_h -= ui_menu_entry_height(mentry); 148 /* NOTE: max_caption_w/max_shortcut_w not updated (speed) */ 149 147 150 list_remove(&mentry->lentries); 151 152 /* 153 * If we emptied the menu, reset accumulated dims so they 154 * can be correctly calculated when (if) the menu is 155 * re-populated. 156 */ 157 if (list_empty(&mentry->menu->entries)) { 158 mentry->menu->total_h = 0; 159 mentry->menu->max_caption_w = 0; 160 mentry->menu->max_shortcut_w = 0; 161 } 162 148 163 free(mentry->caption); 149 164 free(mentry); -
uspace/lib/ui/src/popup.c
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 190 190 } 191 191 192 /** Get ID of device that sent the last position event. 193 * 194 * @param popup Popup window 195 * @return Input device ID 196 */ 197 sysarg_t ui_popup_get_idev_id(ui_popup_t *popup) 198 { 199 return popup->idev_id; 200 } 201 192 202 /** Handle close event in popup window. 193 203 * … … 214 224 ui_popup_t *popup = (ui_popup_t *)arg; 215 225 226 /* Remember ID of device that sent the last event */ 227 popup->idev_id = event->kbd_id; 228 216 229 if (popup->cb != NULL && popup->cb->kbd != NULL) 217 230 popup->cb->kbd(popup, popup->arg, event); … … 229 242 ui_popup_t *popup = (ui_popup_t *)arg; 230 243 244 /* Remember ID of device that sent the last event */ 245 popup->idev_id = event->pos_id; 246 231 247 if (popup->cb != NULL && popup->cb->pos != NULL) 232 248 popup->cb->pos(popup, popup->arg, event); -
uspace/lib/ui/src/wdecor.c
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 45 45 #include <ui/paint.h> 46 46 #include <ui/pbutton.h> 47 #include <ui/ui.h> 47 48 #include <ui/wdecor.h> 48 49 #include "../private/resource.h" … … 94 95 /** Window resizing edge height */ 95 96 wdecor_edge_h = 4, 97 /** Window resizing edge witdth */ 98 wdecor_edge_w_text = 1, 99 /** Window resizing edge height */ 100 wdecor_edge_h_text = 1, 96 101 /** Title bar height */ 97 102 wdecor_tbar_h = 22, … … 860 865 * and its decoration. 861 866 * 867 * @param ui UI 862 868 * @param style Decoration style 863 869 * @param app Application area rectangle 864 870 * @param rect Place to store (outer) window decoration rectangle 865 871 */ 866 void ui_wdecor_rect_from_app(ui_wdecor_style_t style, gfx_rect_t *app, 867 gfx_rect_t *rect) 868 { 872 void ui_wdecor_rect_from_app(ui_t *ui, ui_wdecor_style_t style, 873 gfx_rect_t *app, gfx_rect_t *rect) 874 { 875 bool textmode; 876 gfx_coord_t edge_w, edge_h; 869 877 *rect = *app; 870 878 879 textmode = ui_is_textmode(ui); 880 if (textmode) { 881 edge_w = wdecor_edge_w_text; 882 edge_h = wdecor_edge_h_text; 883 } else { 884 edge_w = wdecor_edge_w; 885 edge_h = wdecor_edge_h; 886 } 887 871 888 if ((style & ui_wds_frame) != 0) { 872 rect->p0.x -= wdecor_edge_w;873 rect->p0.y -= wdecor_edge_h;874 rect->p1.x += wdecor_edge_w;875 rect->p1.y += wdecor_edge_h;876 } 877 878 if ((style & ui_wds_titlebar) != 0 )879 rect->p0.y -= 22;889 rect->p0.x -= edge_w; 890 rect->p0.y -= edge_h; 891 rect->p1.x += edge_w; 892 rect->p1.y += edge_h; 893 } 894 895 if ((style & ui_wds_titlebar) != 0 && !textmode) 896 rect->p0.y -= wdecor_tbar_h; 880 897 } 881 898 -
uspace/lib/ui/test/wdecor.c
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 34 34 #include <ui/pbutton.h> 35 35 #include <ui/resource.h> 36 #include <ui/ui.h> 36 37 #include <ui/wdecor.h> 37 38 #include "../private/wdecor.h" … … 1322 1323 PCUT_TEST(rect_from_app) 1323 1324 { 1325 errno_t rc; 1326 ui_t *ui = NULL; 1324 1327 gfx_rect_t arect; 1325 1328 gfx_rect_t rect; 1329 1330 rc = ui_create_disp(NULL, &ui); 1331 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1326 1332 1327 1333 arect.p0.x = 14; … … 1330 1336 arect.p1.y = 196; 1331 1337 1332 ui_wdecor_rect_from_app(ui _wds_none, &arect, &rect);1338 ui_wdecor_rect_from_app(ui, ui_wds_none, &arect, &rect); 1333 1339 1334 1340 PCUT_ASSERT_INT_EQUALS(14, rect.p0.x); … … 1337 1343 PCUT_ASSERT_INT_EQUALS(196, rect.p1.y); 1338 1344 1339 ui_wdecor_rect_from_app(ui _wds_frame, &arect, &rect);1345 ui_wdecor_rect_from_app(ui, ui_wds_frame, &arect, &rect); 1340 1346 1341 1347 PCUT_ASSERT_INT_EQUALS(10, rect.p0.x); … … 1344 1350 PCUT_ASSERT_INT_EQUALS(200, rect.p1.y); 1345 1351 1346 ui_wdecor_rect_from_app(ui _wds_decorated, &arect, &rect);1352 ui_wdecor_rect_from_app(ui, ui_wds_decorated, &arect, &rect); 1347 1353 1348 1354 PCUT_ASSERT_INT_EQUALS(10, rect.p0.x); … … 1351 1357 PCUT_ASSERT_INT_EQUALS(200, rect.p1.y); 1352 1358 1359 ui_destroy(ui); 1353 1360 } 1354 1361 -
uspace/lib/usbhid/src/hidparser.c
re4cc266 r34aad53d 225 225 /* Than we take the higher bits from the LSB */ 226 226 const unsigned bit_offset = item->offset % 8; 227 const int lsb_bits = min( bits, 8);227 const int lsb_bits = min((unsigned)bits, 8 - bit_offset); 228 228 229 229 value |= (*data >> bit_offset) & BIT_RRANGE(uint8_t, lsb_bits); -
uspace/srv/hid/output/port/ega.c
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * Copyright (c) 2011 Martin Decky 4 4 * All rights reserved. … … 90 90 break; 91 91 case CHAR_ATTR_RGB: 92 attr = (attrs.val.rgb.bgcolor < attrs.val.rgb.fgcolor) ? 93 ega.style_inverted : ega.style_normal; 92 attr = 93 ((RED(attrs.val.rgb.fgcolor) >= 0x80) ? 0x40 : 0) | 94 ((GREEN(attrs.val.rgb.fgcolor) >= 0x80) ? 0x20 : 0) | 95 ((BLUE(attrs.val.rgb.fgcolor) >= 0x80) ? 0x10 : 0) | 96 ((RED(attrs.val.rgb.bgcolor) >= 0x80) ? 0x04 : 0) | 97 ((GREEN(attrs.val.rgb.bgcolor) >= 0x80) ? 0x02 : 0) | 98 ((BLUE(attrs.val.rgb.bgcolor) >= 0x80) ? 0x01 : 0); 94 99 break; 95 100 } -
uspace/srv/locsrv/locsrv.c
re4cc266 r34aad53d 1 1 /* 2 * Copyright (c) 2024 Jiri Svoboda 2 3 * Copyright (c) 2007 Josef Cejka 3 * Copyright (c) 2011 Jiri Svoboda4 4 * All rights reserved. 5 5 * … … 1354 1354 categ_dir_add_cat(&cdir, cat); 1355 1355 1356 cat = category_new("tbarcfg-notif"); 1357 categ_dir_add_cat(&cdir, cat); 1358 1356 1359 cat = category_new("test3"); 1357 1360 categ_dir_add_cat(&cdir, cat); -
version
re4cc266 r34aad53d 28 28 29 29 30 HELENOS_RELEASE = 0.1 2.131 HELENOS_CODENAME = Cathode32 HELENOS_COPYRIGHT = Copyright (c) 2001-202 2HelenOS project30 HELENOS_RELEASE = 0.14.1 31 HELENOS_CODENAME = Aladar 32 HELENOS_COPYRIGHT = Copyright (c) 2001-2024 HelenOS project
Note:
See TracChangeset
for help on using the changeset viewer.