Changes in / [c37c24c:6c1e7c0] in mainline
- Files:
-
- 5 added
- 36 deleted
- 49 edited
Legend:
- Unmodified
- Added
- Removed
-
README.md
rc37c24c r6c1e7c0 10 10 extensible, fault tolerant and easy to understand. 11 11 12 ![screenshot](http://www.helenos.org/raw-attachment/wiki/Screenshots/ gui-14.1-aio.png "Screenshot")12 ![screenshot](http://www.helenos.org/raw-attachment/wiki/Screenshots/newgui-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
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2023 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,205 203 INTERFACE_PCAP_CONTROL = 206 204 FOURCC_COMPACT('p', 'c', 't', 'l') | IFACE_EXCHANGE_SERIALIZE, -
defaults/ia64/Makefile.config
rc37c24c r6c1e7c0 51 51 52 52 # Optimization level 53 OPTIMIZATION = 253 OPTIMIZATION = 3 -
meson/part/initrd_manifest/meson.build
rc37c24c r6c1e7c0 68 68 if CONFIG_FB 69 69 rd_essential += [ 70 'app/ taskbar',70 'app/launcher', 71 71 'app/terminal', 72 72 -
tools/export.sh
rc37c24c r6c1e7c0 43 43 uspace/lib/libc.a \ 44 44 uspace/lib/libcongfx.a \ 45 uspace/lib/libconsole.a \46 45 uspace/lib/libcpp.a \ 47 46 uspace/lib/libdisplay.a \ … … 49 48 uspace/lib/libgfxfont.a \ 50 49 uspace/lib/libgfximage.a \ 51 uspace/lib/libinput.a \52 50 uspace/lib/libhound.a \ 53 51 uspace/lib/libipcgfx.a \ 54 52 uspace/lib/libmath.a \ 55 53 uspace/lib/libmemgfx.a \ 56 uspace/lib/liboutput.a \57 54 uspace/lib/libpcm.a \ 58 55 uspace/lib/libpixconv.a \ -
tools/mkarray.py
rc37c24c r6c1e7c0 39 39 def usage(prname): 40 40 "Print usage syntax" 41 print("%s [--deflate] <DESTINATION> < TYPENAME> <LABEL> <AS_PROLOG> <SECTION> [SOURCE ...]" % prname)41 print("%s [--deflate] <DESTINATION> <LABEL> <AS_PROLOG> <SECTION> [SOURCE ...]" % prname) 42 42 43 43 def arg_check(): 44 if (len(sys.argv) < 6):44 if (len(sys.argv) < 5): 45 45 usage(sys.argv[0]) 46 46 sys.exit() … … 66 66 67 67 dest = sys.argv[1] 68 typename = sys.argv[2] 69 label = sys.argv[3] 70 as_prolog = sys.argv[4] 71 section = sys.argv[5] 68 label = sys.argv[2] 69 as_prolog = sys.argv[3] 70 section = sys.argv[4] 72 71 73 72 timestamp = (1980, 1, 1, 0, 0, 0) … … 82 81 archive = zipfile.ZipFile("%s.zip" % dest, "w", zipfile.ZIP_STORED) 83 82 84 for src in sys.argv[ 6:]:83 for src in sys.argv[5:]: 85 84 basename = os.path.basename(src) 86 85 plainname = os.path.splitext(basename)[0] … … 148 147 data += "#include <stdbool.h>\n\n" 149 148 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()152 149 data += "typedef struct {\n" 153 150 data += "\tconst char *name;\n" … … 156 153 data += "\tsize_t inflated;\n" 157 154 data += "\tbool compressed;\n" 158 data += "} %s_t;\n\n" % typename 159 data += "#endif\n" 160 data += "extern %s_t %ss[];\n\n" % (typename, label) 155 data += "} %s_t;\n\n" % label 156 data += "extern %s_t %ss[];\n\n" % (label, label) 161 157 data += "\n".join(header_ctx) 162 158 data += "\n\n" … … 183 179 data += ' */\n\n' 184 180 data += "#include \"%s.h\"\n\n" % dest 185 data += "%s_t %ss[] = {\n" % ( typename, label)181 data += "%s_t %ss[] = {\n" % (label, label) 186 182 data += ",\n".join(desc_ctx) 187 183 data += "\n" -
tools/mkarray_for_meson.sh
rc37c24c r6c1e7c0 42 42 _arg3="$4" 43 43 _arg4="$5" 44 _arg5="$6"45 44 _inputs="" 46 45 47 shift 646 shift 5 48 47 49 48 for file in "$@"; do … … 52 51 53 52 cd $_outdir 54 $TOOLS_DIR/mkarray.py "$_arg1" "$_arg2" "$_arg3" "$_arg4" "$_arg5"$_inputs > /dev/null53 $TOOLS_DIR/mkarray.py "$_arg1" "$_arg2" "$_arg3" "$_arg4" $_inputs > /dev/null -
tools/xcw/bin/helenos-pkg-config
rc37c24c r6c1e7c0 93 93 config = args.parse_args() 94 94 95 export_dir = os.getenv('EXPORT_DIR', get_build_root() + '/export')95 export_dir = os.getenv('EXPORT_DIR', get_build_root()) 96 96 97 97 result = [] -
uspace/app/barber/barber.c
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2020 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"53 52 54 53 #define NAME "barber" … … 61 60 #define MIN_LOAD (LOAD_UNIT / 4) 62 61 #define MAX_LOAD (LOAD_UNIT / 3) 62 63 #define FRAME_WIDTH 59 64 #define FRAME_HEIGHT 192 63 65 64 66 #define LED_PERIOD 1000000 … … 95 97 static unsigned int frame = 0; 96 98 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 *);105 104 106 105 static ui_window_cb_t window_cb = { 107 .close = wnd_close, 108 .kbd = wnd_kbd_event 106 .close = wnd_close 109 107 }; 110 108 … … 112 110 * 113 111 * @param window Window 114 * @param arg Argument ( barber)112 * @param arg Argument (launcher) 115 113 */ 116 114 static void wnd_close(ui_window_t *window, void *arg) … … 121 119 } 122 120 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) 121 static bool decode_frames(gfx_context_t *gc) 169 122 { 170 123 gfx_rect_t rect; … … 172 125 173 126 for (unsigned int i = 0; i < FRAMES; i++) { 174 rc = decode_tga_gz(gc, im g[i].addr, img[i].size,127 rc = decode_tga_gz(gc, images[i].addr, images[i].size, 175 128 &frame_bmp[i], &rect); 176 129 if (rc != EOK) { … … 179 132 } 180 133 181 (void) rect;134 (void) rect; 182 135 } 183 136 … … 285 238 rect.p0.x = 0; 286 239 rect.p0.y = 0; 287 rect.p1.x = frame_width;288 rect.p1.y = frame_height;240 rect.p1.x = FRAME_WIDTH; 241 rect.p1.y = FRAME_HEIGHT; 289 242 290 243 ui_image_set_bmp(frame_img, frame_bmp[frame], &rect); … … 346 299 int main(int argc, char *argv[]) 347 300 { 348 const char *display_spec = UI_ ANY_DEFAULT;301 const char *display_spec = UI_DISPLAY_DEFAULT; 349 302 barber_t barber; 350 303 ui_t *ui; … … 357 310 gfx_context_t *gc; 358 311 gfx_coord2_t off; 359 image_t *img;360 312 int i; 361 313 … … 403 355 } 404 356 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 413 357 rect.p0.x = 0; 414 358 rect.p0.y = 0; 415 rect.p1.x = frame_width;416 rect.p1.y = frame_height;359 rect.p1.x = FRAME_WIDTH; 360 rect.p1.y = FRAME_HEIGHT; 417 361 418 362 ui_wnd_params_init(¶ms); … … 423 367 * to rect 424 368 */ 425 ui_wdecor_rect_from_app( ui,params.style, &rect, &wrect);369 ui_wdecor_rect_from_app(params.style, &rect, &wrect); 426 370 off = wrect.p0; 427 371 gfx_rect_rtranslate(&off, &wrect, ¶ms.rect); … … 440 384 ui_window_set_cb(window, &window_cb, (void *) &barber); 441 385 442 img = ui_is_textmode(ui) ? image_tinys : images; 443 444 if (!decode_frames(gc, img)) 386 if (!decode_frames(gc)) 445 387 return 1; 446 388 -
uspace/app/barber/meson.build
rc37c24c r6c1e7c0 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 97 64 _tarball = custom_target('barber_images.tar', 98 65 input: _images, … … 103 70 # TODO 104 71 105 # Normal images106 107 72 _images_zip = custom_target('barber_images.zip', 108 73 input : _images, 109 74 output : [ 'images.zip' ], 110 command : [ mkarray, '@OUTDIR@', 'images', 'image', 'image',uspace_as_prolog, '.data', '@INPUT@' ],75 command : [ mkarray, '@OUTDIR@', 'images', 'image', uspace_as_prolog, '.data', '@INPUT@' ], 111 76 ) 112 77 _imgs_s = custom_target('barber_images.s', … … 129 94 ) 130 95 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 ] 96 src = [ files('barber.c'), _imgs_s, _imgs_h, _imgs_desc_c ] -
uspace/app/fontedit/fontedit.c
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 787 787 * to rect 788 788 */ 789 ui_wdecor_rect_from_app( ui,params.style, &rect, &wrect);789 ui_wdecor_rect_from_app(params.style, &rect, &wrect); 790 790 off = wrect.p0; 791 791 gfx_rect_rtranslate(&off, &wrect, ¶ms.rect); -
uspace/app/gfxdemo/gfxdemo.c
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2023 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( 255, (i % 30) < 3 ? 255 : 0,395 PIXEL(0, (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( 255, k, k, k));431 PIXEL(0, 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( 255, 0, 255, 0) :467 PIXEL( 255, 255, 0, 255));466 k < w * w / 2 ? PIXEL(0, 0, 255, 0) : 467 PIXEL(0, 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( 255, 255, 0, 255);623 params.key_color = PIXEL(0, 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( ui,params.style, &rect, &wrect);1162 ui_wdecor_rect_from_app(params.style, &rect, &wrect); 1163 1163 off = wrect.p0; 1164 1164 gfx_rect_rtranslate(&off, &wrect, ¶ms.rect); -
uspace/app/init/init.c
rc37c24c r6c1e7c0 476 476 rc = display_server(); 477 477 if (rc == EOK) { 478 app_start("/app/launcher", NULL); 478 479 app_start("/app/taskbar", NULL); 479 480 app_start("/app/terminal", "-topleft"); -
uspace/app/meson.build
rc37c24c r6c1e7c0 28 28 29 29 apps = [ 30 'aboutos',31 30 'barber', 32 31 'bdsh', … … 58 57 'killall', 59 58 'kio', 59 'launcher', 60 60 'loc', 61 61 'logset', -
uspace/app/nav/test/panel.c
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2022 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); 64 } 65 66 /** panel_set_cb() sets callback */ 67 PCUT_TEST(set_cb) 68 { 69 panel_t *panel; 70 errno_t rc; 71 test_resp_t resp; 72 73 rc = panel_create(NULL, true, &panel); 74 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 75 76 panel_set_cb(panel, &test_cb, &resp); 77 PCUT_ASSERT_EQUALS(&test_cb, panel->cb); 78 PCUT_ASSERT_EQUALS(&resp, panel->cb_arg); 79 80 panel_destroy(panel); 81 } 82 83 /** Test panel_paint() */ 84 PCUT_TEST(paint) 85 { 57 86 ui_t *ui; 58 87 ui_window_t *window; … … 73 102 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 74 103 104 rc = panel_paint(panel); 105 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 106 75 107 panel_destroy(panel); 76 108 ui_window_destroy(window); … … 78 110 } 79 111 80 /** panel_set_cb() sets callback */81 PCUT_TEST(set_cb)82 {83 ui_t *ui;84 ui_window_t *window;85 ui_wnd_params_t params;86 panel_t *panel;87 errno_t rc;88 test_resp_t resp;89 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);100 PCUT_ASSERT_ERRNO_VAL(EOK, rc);101 102 panel_set_cb(panel, &test_cb, &resp);103 PCUT_ASSERT_EQUALS(&test_cb, panel->cb);104 PCUT_ASSERT_EQUALS(&resp, panel->cb_arg);105 106 panel_destroy(panel);107 ui_window_destroy(window);108 ui_destroy(ui);109 }110 111 /** Test panel_paint() */112 PCUT_TEST(paint)113 {114 ui_t *ui;115 ui_window_t *window;116 ui_wnd_params_t params;117 panel_t *panel;118 errno_t rc;119 120 rc = ui_create_disp(NULL, &ui);121 PCUT_ASSERT_ERRNO_VAL(EOK, rc);122 123 ui_wnd_params_init(¶ms);124 params.caption = "Test";125 126 rc = ui_window_create(ui, ¶ms, &window);127 PCUT_ASSERT_ERRNO_VAL(EOK, rc);128 129 rc = panel_create(window, true, &panel);130 PCUT_ASSERT_ERRNO_VAL(EOK, rc);131 132 rc = panel_paint(panel);133 PCUT_ASSERT_ERRNO_VAL(EOK, rc);134 135 panel_destroy(panel);136 ui_window_destroy(window);137 ui_destroy(ui);138 }139 140 112 /** panel_ctl() returns a valid UI control */ 141 113 PCUT_TEST(ctl) 142 114 { 143 ui_t *ui;144 ui_window_t *window;145 ui_wnd_params_t params;146 115 panel_t *panel; 147 116 ui_control_t *control; 148 117 errno_t rc; 149 118 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); 119 rc = panel_create(NULL, true, &panel); 160 120 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 161 121 … … 164 124 165 125 panel_destroy(panel); 166 ui_window_destroy(window);167 ui_destroy(ui);168 126 } 169 127 … … 171 129 PCUT_TEST(kbd_event) 172 130 { 173 ui_t *ui;174 ui_window_t *window;175 ui_wnd_params_t params;176 131 panel_t *panel; 177 132 ui_evclaim_t claimed; … … 181 136 /* Active panel should claim events */ 182 137 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); 138 rc = panel_create(NULL, true, &panel); 193 139 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 194 140 … … 205 151 /* Inactive panel should not claim events */ 206 152 207 rc = panel_create( window, false, &panel);153 rc = panel_create(NULL, false, &panel); 208 154 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 209 155 … … 217 163 218 164 panel_destroy(panel); 219 ui_window_destroy(window);220 ui_destroy(ui);221 165 } 222 166 … … 229 173 PCUT_TEST(set_rect) 230 174 { 231 ui_t *ui;232 ui_window_t *window;233 ui_wnd_params_t params;234 175 panel_t *panel; 235 176 gfx_rect_t rect; 236 177 errno_t rc; 237 178 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); 179 rc = panel_create(NULL, true, &panel); 248 180 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 249 181 … … 260 192 261 193 panel_destroy(panel); 262 ui_window_destroy(window);263 ui_destroy(ui);264 194 } 265 195 266 196 /** panel_is_active() returns panel activity state */ 267 197 PCUT_TEST(is_active) 198 { 199 panel_t *panel; 200 errno_t rc; 201 202 rc = panel_create(NULL, true, &panel); 203 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 204 PCUT_ASSERT_TRUE(panel_is_active(panel)); 205 panel_destroy(panel); 206 207 rc = panel_create(NULL, false, &panel); 208 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 209 PCUT_ASSERT_FALSE(panel_is_active(panel)); 210 panel_destroy(panel); 211 } 212 213 /** panel_activate() activates panel */ 214 PCUT_TEST(activate) 268 215 { 269 216 ui_t *ui; … … 282 229 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 283 230 284 rc = panel_create(window, true, &panel); 231 rc = panel_create(window, false, &panel); 232 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 233 234 PCUT_ASSERT_FALSE(panel_is_active(panel)); 235 rc = panel_activate(panel); 285 236 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 286 237 PCUT_ASSERT_TRUE(panel_is_active(panel)); 287 panel_destroy(panel); 288 289 rc = panel_create(window, false, &panel); 290 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 291 PCUT_ASSERT_FALSE(panel_is_active(panel)); 238 292 239 panel_destroy(panel); 293 240 ui_window_destroy(window); … … 295 242 } 296 243 297 /** panel_ activate()activates panel */298 PCUT_TEST( activate)244 /** panel_deactivate() deactivates panel */ 245 PCUT_TEST(deactivate) 299 246 { 300 247 ui_t *ui; … … 313 260 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 314 261 315 rc = panel_create(window, false, &panel);316 PCUT_ASSERT_ERRNO_VAL(EOK, rc);317 318 PCUT_ASSERT_FALSE(panel_is_active(panel));319 rc = panel_activate(panel);320 PCUT_ASSERT_ERRNO_VAL(EOK, rc);321 PCUT_ASSERT_TRUE(panel_is_active(panel));322 323 panel_destroy(panel);324 ui_window_destroy(window);325 ui_destroy(ui);326 }327 328 /** panel_deactivate() deactivates panel */329 PCUT_TEST(deactivate)330 {331 ui_t *ui;332 ui_window_t *window;333 ui_wnd_params_t params;334 panel_t *panel;335 errno_t rc;336 337 rc = ui_create_disp(NULL, &ui);338 PCUT_ASSERT_ERRNO_VAL(EOK, rc);339 340 ui_wnd_params_init(¶ms);341 params.caption = "Test";342 343 rc = ui_window_create(ui, ¶ms, &window);344 PCUT_ASSERT_ERRNO_VAL(EOK, rc);345 346 262 rc = panel_create(window, true, &panel); 347 263 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 359 275 PCUT_TEST(activate_req) 360 276 { 361 ui_t *ui;362 ui_window_t *window;363 ui_wnd_params_t params;364 277 panel_t *panel; 365 278 errno_t rc; 366 279 test_resp_t resp; 367 280 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); 281 rc = panel_create(NULL, true, &panel); 378 282 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 379 283 … … 388 292 389 293 panel_destroy(panel); 390 ui_window_destroy(window);391 ui_destroy(ui);392 294 } 393 295 -
uspace/app/taskbar-cfg/smeedit.c
rc37c24c r6c1e7c0 403 403 404 404 startmenu_repaint(smee->startmenu); 405 (void)tbarcfg_notify(TBARCFG_NOTIFY_DEFAULT);406 405 } else { 407 406 /* Edit existing entry */ … … 420 419 (void)smenu_entry_save(smee->smentry->entry); 421 420 startmenu_entry_update(smee->smentry); 422 (void)tbarcfg_notify(TBARCFG_NOTIFY_DEFAULT);423 421 } 424 422 -
uspace/app/taskbar-cfg/startmenu.c
rc37c24c r6c1e7c0 515 515 516 516 (void)smee; 517 (void)tbarcfg_notify(TBARCFG_NOTIFY_DEFAULT);518 517 } 519 518 … … 534 533 (void)startmenu_insert(smenu, entry, &smentry); 535 534 (void)ui_control_paint(ui_list_ctl(smenu->entries_list)); 536 (void)tbarcfg_notify(TBARCFG_NOTIFY_DEFAULT);537 535 } 538 536 … … 635 633 free(smentry); 636 634 (void)ui_control_paint(ui_list_ctl(smenu->entries_list)); 637 (void)tbarcfg_notify(TBARCFG_NOTIFY_DEFAULT);638 635 } 639 636 … … 688 685 689 686 (void)ui_control_paint(ui_list_ctl(smenu->entries_list)); 690 (void)tbarcfg_notify(TBARCFG_NOTIFY_DEFAULT);691 687 } 692 688 … … 708 704 return; 709 705 710 rc = smenu_entry_move_ down(smentry->entry);706 rc = smenu_entry_move_up(smentry->entry); 711 707 if (rc != EOK) 712 708 return; … … 715 711 716 712 (void)ui_control_paint(ui_list_ctl(smenu->entries_list)); 717 (void)tbarcfg_notify(TBARCFG_NOTIFY_DEFAULT);718 713 } 719 714 -
uspace/app/taskbar/meson.build
rc37c24c r6c1e7c0 48 48 ) 49 49 50 installed_data += { 'name': 'taskbar.sif', 'dir': '/cfg' } 50 if install_nonessential_data 51 installed_data += { 'name': 'taskbar.sif', 'dir': '/cfg' } 52 endif -
uspace/app/taskbar/taskbar.c
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2023 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 52 50 static void taskbar_wnd_close(ui_window_t *, void *); 53 51 static void taskbar_wnd_kbd(ui_window_t *, void *, kbd_event_t *); 54 52 static void taskbar_wnd_pos(ui_window_t *, void *, pos_event_t *); 55 static void taskbar_notif_cb(void *);56 53 57 54 static ui_window_cb_t window_cb = { … … 131 128 gfx_rect_t scr_rect; 132 129 gfx_rect_t rect; 133 char *dspec = NULL;134 char *qmark;135 130 errno_t rc; 136 131 137 132 taskbar = calloc(1, sizeof(taskbar_t)); 138 133 if (taskbar == NULL) { 139 printf("Out of memory.\n");140 134 rc = ENOMEM; 141 135 goto error; 142 136 } 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';155 137 156 138 rc = ui_create(display_spec, &taskbar->ui); … … 213 195 } 214 196 215 rc = tbsmenu_create(taskbar->window, taskbar->fixed, dspec, 216 &taskbar->tbsmenu); 197 rc = tbsmenu_create(taskbar->window, taskbar->fixed, &taskbar->tbsmenu); 217 198 if (rc != EOK) { 218 199 printf("Error creating start menu.\n"); … … 220 201 } 221 202 222 rc = tbsmenu_load(taskbar->tbsmenu, TASKBAR_CONFIG_FILE);203 rc = tbsmenu_load(taskbar->tbsmenu, "/cfg/taskbar.sif"); 223 204 if (rc != EOK) { 224 205 printf("Error loading start menu from '%s'.\n", 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"); 206 "/cfg/taskbar.sif"); 232 207 } 233 208 … … 309 284 } 310 285 311 free(dspec);312 286 *rtaskbar = taskbar; 313 287 return EOK; 314 288 error: 315 if (dspec != NULL)316 free(dspec);317 if (taskbar->lst != NULL)318 tbarcfg_listener_destroy(taskbar->lst);319 289 if (taskbar->clock != NULL) 320 290 taskbar_clock_destroy(taskbar->clock); … … 327 297 if (taskbar->ui != NULL) 328 298 ui_destroy(taskbar->ui); 329 free(taskbar);330 299 return rc; 331 300 … … 335 304 void taskbar_destroy(taskbar_t *taskbar) 336 305 { 337 if (taskbar->lst != NULL)338 tbarcfg_listener_destroy(taskbar->lst);339 306 ui_fixed_remove(taskbar->fixed, taskbar_clock_ctl(taskbar->clock)); 340 307 taskbar_clock_destroy(taskbar->clock); … … 345 312 } 346 313 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 362 314 /** @} 363 315 */ -
uspace/app/taskbar/taskbar.sif
rc37c24c r6c1e7c0 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]){}}}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]){}}} -
uspace/app/taskbar/tbsmenu.c
rc37c24c r6c1e7c0 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 *);67 66 68 67 /** Create taskbar start menu. … … 70 69 * @param window Containing window 71 70 * @param fixed Fixed layout to which start button will be added 72 * @param dspec Display specification (for passing to applications)73 71 * @param rtbsmenu Place to store pointer to new start menu 74 72 * @return @c EOK on success or an error code 75 73 */ 76 74 errno_t tbsmenu_create(ui_window_t *window, ui_fixed_t *fixed, 77 const char *dspec,tbsmenu_t **rtbsmenu)75 tbsmenu_t **rtbsmenu) 78 76 { 79 77 ui_resource_t *res = ui_window_get_res(window); … … 87 85 } 88 86 89 tbsmenu->display_spec = str_dup(dspec);90 if (tbsmenu->display_spec == NULL) {91 rc = ENOMEM;92 goto error;93 }94 95 87 rc = ui_pbutton_create(res, "Start", &tbsmenu->sbutton); 96 88 if (rc != EOK) … … 119 111 return EOK; 120 112 error: 121 if (tbsmenu != NULL && tbsmenu->display_spec != NULL)122 free(tbsmenu->display_spec);123 113 if (tbsmenu != NULL) 124 114 ui_pbutton_destroy(tbsmenu->sbutton); … … 144 134 bool terminal; 145 135 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 }160 136 161 137 rc = tbarcfg_open(repopath, &tbcfg); … … 194 170 } 195 171 196 /** Reload start menu from repository (or schedule reload).197 *198 * @param tbsmenu Start menu199 */200 void tbsmenu_reload(tbsmenu_t *tbsmenu)201 {202 if (!tbsmenu_is_open(tbsmenu))203 (void) tbsmenu_load(tbsmenu, tbsmenu->repopath);204 else205 tbsmenu->needs_reload = true;206 }207 208 172 /** Set start menu rectangle. 209 173 * … … 234 198 { 235 199 ui_menu_close(tbsmenu->smenu); 236 237 if (tbsmenu->needs_reload)238 (void) tbsmenu_load(tbsmenu, tbsmenu->repopath);239 200 } 240 201 … … 486 447 static errno_t tbsmenu_cmd_split(const char *str, tbsmenu_cmd_t *cmd) 487 448 { 488 char *buf;489 449 char *arg; 490 450 char *next; 491 451 size_t cnt; 492 452 493 buf = str_dup(str);494 if ( buf == NULL)453 cmd->buf = str_dup(str); 454 if (cmd->buf == NULL) 495 455 return ENOMEM; 496 456 497 457 /* Count the entries */ 498 458 cnt = 0; 499 arg = str_tok( buf, " ", &next);459 arg = str_tok(cmd->buf, " ", &next); 500 460 while (arg != NULL) { 501 461 ++cnt; … … 504 464 505 465 /* Need to copy again as buf was mangled */ 506 free( buf);507 buf = str_dup(str);508 if ( buf == NULL)466 free(cmd->buf); 467 cmd->buf = str_dup(str); 468 if (cmd->buf == NULL) 509 469 return ENOMEM; 510 470 511 471 cmd->argv = calloc(cnt + 1, sizeof(char *)); 512 472 if (cmd->argv == NULL) { 513 free( buf);473 free(cmd->buf); 514 474 return ENOMEM; 515 475 } 516 476 517 /* Copy individual arguments */477 /* Fill in pointers */ 518 478 cnt = 0; 519 arg = str_tok( buf, " ", &next);479 arg = str_tok(cmd->buf, " ", &next); 520 480 while (arg != NULL) { 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 481 cmd->argv[cnt++] = arg; 528 482 arg = str_tok(next, " ", &next); 529 483 } … … 540 494 static void tbsmenu_cmd_fini(tbsmenu_cmd_t *cmd) 541 495 { 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 */552 496 free(cmd->argv); 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; 497 free(cmd->buf); 583 498 } 584 499 … … 601 516 char **cp; 602 517 const char **targv = NULL; 603 char *dspec = NULL;604 sysarg_t idev_id;605 int rv;606 518 errno_t rc; 607 519 ui_t *ui; … … 610 522 suspended = false; 611 523 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 */620 524 rc = tbsmenu_cmd_split(entry->cmd, &cmd); 621 if (rc != EOK) { 622 free(dspec); 525 if (rc != EOK) 623 526 return rc; 624 }625 626 /* Substitute metacharacters in command */627 rc = tbsmenu_cmd_subst(&cmd, entry, dspec);628 if (rc != EOK)629 goto error;630 527 631 528 /* Free up and clean console for the child task. */ … … 645 542 } 646 543 647 targv = calloc(cnt + 5, sizeof(char **));544 targv = calloc(cnt + 3, sizeof(char **)); 648 545 if (targv == NULL) 649 546 goto error; 650 547 651 548 targv[0] = "/app/terminal"; 652 targv[1] = "-d"; 653 targv[2] = dspec; 654 targv[3] = "-c"; 549 targv[1] = "-c"; 655 550 656 551 for (i = 0; i <= cnt; i++) { 657 targv[ 4+ i] = cmd.argv[i];552 targv[2 + i] = cmd.argv[i]; 658 553 } 659 554 … … 683 578 return EOK; 684 579 error: 685 free(dspec);686 580 if (targv != NULL) 687 581 free(targv); -
uspace/app/taskbar/tbsmenu.h
rc37c24c r6c1e7c0 46 46 #include "types/tbsmenu.h" 47 47 48 extern errno_t tbsmenu_create(ui_window_t *, ui_fixed_t *, const char *, 49 tbsmenu_t **); 48 extern errno_t tbsmenu_create(ui_window_t *, ui_fixed_t *, tbsmenu_t **); 50 49 extern errno_t tbsmenu_load(tbsmenu_t *, const char *); 51 extern void tbsmenu_reload(tbsmenu_t *);52 50 extern void tbsmenu_set_rect(tbsmenu_t *, gfx_rect_t *); 53 51 extern void tbsmenu_open(tbsmenu_t *); -
uspace/app/taskbar/test/tbsmenu.c
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2023 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, UI_DISPLAY_DEFAULT,&tbsmenu);63 rc = tbsmenu_create(window, fixed, &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, UI_DISPLAY_DEFAULT,&tbsmenu);94 rc = tbsmenu_create(window, fixed, &tbsmenu); 95 95 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 96 96 -
uspace/app/taskbar/types/taskbar.h
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2023 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;64 62 } taskbar_t; 65 63 -
uspace/app/taskbar/types/tbsmenu.h
rc37c24c r6c1e7c0 40 40 #include <gfx/coord.h> 41 41 #include <stdbool.h> 42 #include <tbarcfg/tbarcfg.h>43 42 #include <ui/pbutton.h> 44 43 #include <ui/fixed.h> … … 85 84 /** Device ID of last input event */ 86 85 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;96 86 } tbsmenu_t; 97 87 98 88 /** Command split into individual parts */ 99 89 typedef struct { 90 /** Buffer holding broken down command */ 91 char *buf; 100 92 /** NULL-terminated array of string pointers */ 101 93 char **argv; -
uspace/app/terminal/terminal.c
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2023 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 /* 977 * Compute window rectangle such that application area corresponds 978 * to rect 979 */ 980 ui_wdecor_rect_from_app(wparams.style, &rect, &wrect); 981 off = wrect.p0; 982 gfx_rect_rtranslate(&off, &wrect, &wparams.rect); 983 984 term->off = off; 985 976 986 rc = ui_create(display_spec, &term->ui); 977 987 if (rc != EOK) { … … 979 989 goto error; 980 990 } 981 982 /*983 * Compute window rectangle such that application area corresponds984 * to rect985 */986 ui_wdecor_rect_from_app(term->ui, wparams.style, &rect, &wrect);987 off = wrect.p0;988 gfx_rect_rtranslate(&off, &wrect, &wparams.rect);989 990 term->off = off;991 991 992 992 rc = ui_window_create(term->ui, &wparams, &term->window); -
uspace/app/viewer/viewer.c
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2020 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>43 42 #include <ui/image.h> 44 43 #include <ui/ui.h> … … 51 50 typedef struct { 52 51 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;66 52 } viewer_t; 67 53 68 static bool viewer_img_load(viewer_t *, const char *, gfx_bitmap_t **, 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 **, 69 66 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 *); 67 static bool img_setup(gfx_context_t *, gfx_bitmap_t *, gfx_rect_t *); 73 68 74 69 static void wnd_close(ui_window_t *, void *); … … 80 75 }; 81 76 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_close90 };91 92 77 /** Window close request 93 78 * … … 102 87 } 103 88 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) 89 static void wnd_kbd_event(ui_window_t *window, void *arg, 90 kbd_event_t *event) 110 91 { 111 92 bool update = false; 112 93 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;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; 119 100 else 120 viewer->imgs_current++;101 imgs_current++; 121 102 122 103 update = true; 123 104 } 124 105 125 if ( event->key == KC_PAGE_UP) {126 if ( viewer->imgs_current == 0)127 viewer->imgs_current = viewer->imgs_count - 1;106 if ((event->type == KEY_PRESS) && (event->key == KC_PAGE_UP)) { 107 if (imgs_current == 0) 108 imgs_current = imgs_count - 1; 128 109 else 129 viewer->imgs_current--;110 imgs_current--; 130 111 131 112 update = true; … … 136 117 gfx_rect_t lrect; 137 118 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]); 119 if (!img_load(window_gc, imgs[imgs_current], &lbitmap, &lrect)) { 120 printf("Cannot load image \"%s\".\n", imgs[imgs_current]); 142 121 exit(4); 143 122 } 144 if (!viewer_img_setup(viewer, lbitmap, &lrect)) { 145 printf("Cannot setup image \"%s\".\n", 146 viewer->imgs[viewer->imgs_current]); 123 if (!img_setup(window_gc, lbitmap, &lrect)) { 124 printf("Cannot setup image \"%s\".\n", imgs[imgs_current]); 147 125 exit(6); 148 126 } … … 150 128 } 151 129 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, 130 static bool img_load(gfx_context_t *gc, const char *fname, 249 131 gfx_bitmap_t **rbitmap, gfx_rect_t *rect) 250 132 { … … 277 159 vfs_put(fd); 278 160 279 rc = decode_tga( viewer->window_gc, tga, stat.size, rbitmap, rect);161 rc = decode_tga(gc, tga, stat.size, rbitmap, rect); 280 162 if (rc != EOK) { 281 163 free(tga); … … 285 167 free(tga); 286 168 287 viewer->img_rect = *rect;169 img_rect = *rect; 288 170 return true; 289 171 } 290 172 291 static bool viewer_img_setup(viewer_t *viewer, gfx_bitmap_t *bmp, 292 gfx_rect_t *rect) 173 static bool img_setup(gfx_context_t *gc, gfx_bitmap_t *bmp, gfx_rect_t *rect) 293 174 { 294 175 gfx_rect_t arect; … … 297 178 errno_t rc; 298 179 299 ui_res = ui_window_get_res( viewer->window);300 301 ui_window_get_app_rect( viewer->window, &arect);180 ui_res = ui_window_get_res(window); 181 182 ui_window_get_app_rect(window, &arect); 302 183 303 184 /* Center image on application area */ 304 185 gfx_rect_ctr_on_rect(rect, &arect, &irect); 305 186 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);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); 310 191 } else { 311 rc = ui_image_create(ui_res, bmp, rect, & viewer->image);192 rc = ui_image_create(ui_res, bmp, rect, &image); 312 193 if (rc != EOK) { 313 194 gfx_bitmap_destroy(bmp); … … 315 196 } 316 197 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;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; 325 206 return true; 326 207 } … … 333 214 } 334 215 335 static errno_t viewer_window_create(viewer_t *viewer)336 { 337 ui_wnd_params_t params;216 int main(int argc, char *argv[]) 217 { 218 const char *display_spec = UI_DISPLAY_DEFAULT; 338 219 gfx_bitmap_t *lbitmap; 339 220 gfx_rect_t lrect; 221 bool fullscreen = false; 222 gfx_rect_t rect; 340 223 gfx_rect_t wrect; 341 224 gfx_coord2_t off; 342 gfx_rect_t rect; 225 ui_t *ui; 226 ui_wnd_params_t params; 227 viewer_t viewer; 343 228 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; 344 280 345 281 /* … … 354 290 params.rect.p1.y = 1; 355 291 356 if ( viewer->fullscreen) {292 if (fullscreen) { 357 293 params.style &= ~ui_wds_decorated; 358 294 params.placement = ui_wnd_place_full_screen; 359 295 } 360 296 361 rc = ui_window_create( viewer->ui, ¶ms, &viewer->window);297 rc = ui_window_create(ui, ¶ms, &window); 362 298 if (rc != EOK) { 363 299 printf("Error creating window.\n"); 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; 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; 376 310 } 377 311 … … 380 314 * to rect 381 315 */ 382 ui_wdecor_rect_from_app( viewer->ui,params.style, &lrect, &wrect);316 ui_wdecor_rect_from_app(params.style, &lrect, &wrect); 383 317 off = wrect.p0; 384 318 gfx_rect_rtranslate(&off, &wrect, &rect); 385 319 386 if (! viewer->fullscreen) {387 rc = ui_window_resize( viewer->window, &rect);320 if (!fullscreen) { 321 rc = ui_window_resize(window, &rect); 388 322 if (rc != EOK) { 389 323 printf("Error resizing window.\n"); 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); 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); 401 334 if (rc != EOK) { 402 335 printf("Error painting window.\n"); 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); 336 return 1; 505 337 } 506 338 507 339 ui_run(ui); 508 340 509 ui_window_destroy(viewer->window);510 ui_destroy(ui);511 free(viewer);512 513 341 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;531 342 } 532 343 -
uspace/lib/congfx/src/console.c
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 91 91 uint8_t attr; 92 92 93 if ((clr >> 24) == 0 xff) {93 if ((clr >> 24) == 0) { 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 ;98 ch->attrs.val.rgb.fgcolor = clr ^ 0xffffff; 99 99 ch->attrs.val.rgb.bgcolor = clr; 100 100 } else { -
uspace/lib/gfx/src/color.c
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 64 64 color->g = g; 65 65 color->b = b; 66 color->attr = 0xff;67 66 68 67 *rcolor = color; -
uspace/lib/meson.build
rc37c24c r6c1e7c0 33 33 'c', 34 34 'math', 35 'console',36 35 'display', 37 'input',38 'output',39 36 'pixconv', 40 37 'posix', -
uspace/lib/tbarcfg/include/tbarcfg/tbarcfg.h
rc37c24c r6c1e7c0 42 42 #include <types/tbarcfg/tbarcfg.h> 43 43 44 #define TBARCFG_NOTIFY_DEFAULT "tbarcfg-notif"45 46 44 extern errno_t tbarcfg_create(const char *, tbarcfg_t **); 47 45 extern errno_t tbarcfg_open(const char *, tbarcfg_t **); … … 65 63 extern errno_t smenu_entry_move_up(smenu_entry_t *); 66 64 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 *);71 65 72 66 #endif -
uspace/lib/tbarcfg/include/types/tbarcfg/tbarcfg.h
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2023 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 48 45 #endif 49 46 -
uspace/lib/tbarcfg/private/tbarcfg.h
rc37c24c r6c1e7c0 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 81 73 extern errno_t smenu_entry_new(tbarcfg_t *, sif_node_t *, const char *, 82 74 const char *, bool, smenu_entry_t **); -
uspace/lib/tbarcfg/src/tbarcfg.c
rc37c24c r6c1e7c0 34 34 */ 35 35 36 #include <async.h>37 36 #include <errno.h> 38 37 #include <sif.h> 39 #include <ipc/tbarcfg.h>40 #include <loc.h>41 #include <task.h>42 38 #include <tbarcfg/tbarcfg.h> 43 #include <stdio.h>44 39 #include <stdlib.h> 45 40 #include <str.h> 46 41 #include "../private/tbarcfg.h" 47 48 static void tbarcfg_notify_conn(ipc_call_t *, void *);49 42 50 43 /** Create taskbar configuration. … … 791 784 } 792 785 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 listener799 * @return EOK on success or an error code800 */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 Listener865 */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 ID874 * @return EOK on success or an error code875 */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 call934 * @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 965 786 /** @} 966 787 */ -
uspace/lib/tbarcfg/test/tbarcfg.c
rc37c24c r6c1e7c0 30 30 #include <pcut/pcut.h> 31 31 #include <tbarcfg/tbarcfg.h> 32 #include <stdbool.h>33 32 #include <stdio.h> 34 33 … … 36 35 37 36 PCUT_TEST_SUITE(tbarcfg); 38 39 typedef struct {40 bool notified;41 } tbarcfg_test_resp_t;42 43 static void test_cb(void *);44 37 45 38 /** Creating, opening and closing taskbar configuration */ … … 561 554 } 562 555 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 592 556 PCUT_EXPORT(tbarcfg); -
uspace/lib/ui/include/ui/menu.h
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2023 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 *);62 61 63 62 #endif -
uspace/lib/ui/include/ui/popup.h
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2021 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 *);57 56 58 57 #endif -
uspace/lib/ui/include/ui/wdecor.h
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2023 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>47 46 #include <types/ui/wdecor.h> 48 47 … … 59 58 extern ui_evclaim_t ui_wdecor_kbd_event(ui_wdecor_t *, kbd_event_t *); 60 59 extern ui_evclaim_t ui_wdecor_pos_event(ui_wdecor_t *, pos_event_t *); 61 extern void ui_wdecor_rect_from_app(ui_ t *, ui_wdecor_style_t, gfx_rect_t *,60 extern void ui_wdecor_rect_from_app(ui_wdecor_style_t, gfx_rect_t *, 62 61 gfx_rect_t *); 63 62 extern void ui_wdecor_app_from_rect(ui_wdecor_style_t, gfx_rect_t *, -
uspace/lib/ui/private/menu.h
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2023 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;74 72 }; 75 73 -
uspace/lib/ui/private/popup.h
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2021 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;62 60 }; 63 61 -
uspace/lib/ui/src/menu.c
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2023 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);581 580 ui_menu_kbd_event(menu, event); 582 581 } … … 593 592 gfx_coord2_t spos; 594 593 595 menu->idev_id = ui_popup_get_idev_id(menu->popup);596 597 594 spos.x = 0; 598 595 spos.y = 0; … … 644 641 } 645 642 646 /** Get ID of last device that input event.647 *648 * @param menu Menu649 * @return Input device ID650 */651 sysarg_t ui_menu_get_idev_id(ui_menu_t *menu)652 {653 return menu->idev_id;654 }655 656 643 /** @} 657 644 */ -
uspace/lib/ui/src/menuentry.c
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2023 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 150 147 list_remove(&mentry->lentries); 151 152 /*153 * If we emptied the menu, reset accumulated dims so they154 * can be correctly calculated when (if) the menu is155 * 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 163 148 free(mentry->caption); 164 149 free(mentry); -
uspace/lib/ui/src/popup.c
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2023 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 window195 * @return Input device ID196 */197 sysarg_t ui_popup_get_idev_id(ui_popup_t *popup)198 {199 return popup->idev_id;200 }201 202 192 /** Handle close event in popup window. 203 193 * … … 224 214 ui_popup_t *popup = (ui_popup_t *)arg; 225 215 226 /* Remember ID of device that sent the last event */227 popup->idev_id = event->kbd_id;228 229 216 if (popup->cb != NULL && popup->cb->kbd != NULL) 230 217 popup->cb->kbd(popup, popup->arg, event); … … 242 229 ui_popup_t *popup = (ui_popup_t *)arg; 243 230 244 /* Remember ID of device that sent the last event */245 popup->idev_id = event->pos_id;246 247 231 if (popup->cb != NULL && popup->cb->pos != NULL) 248 232 popup->cb->pos(popup, popup->arg, event); -
uspace/lib/ui/src/wdecor.c
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2023 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>48 47 #include <ui/wdecor.h> 49 48 #include "../private/resource.h" … … 95 94 /** Window resizing edge height */ 96 95 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,101 96 /** Title bar height */ 102 97 wdecor_tbar_h = 22, … … 865 860 * and its decoration. 866 861 * 867 * @param ui UI868 862 * @param style Decoration style 869 863 * @param app Application area rectangle 870 864 * @param rect Place to store (outer) window decoration rectangle 871 865 */ 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; 866 void ui_wdecor_rect_from_app(ui_wdecor_style_t style, gfx_rect_t *app, 867 gfx_rect_t *rect) 868 { 877 869 *rect = *app; 878 870 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 888 871 if ((style & ui_wds_frame) != 0) { 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;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; 897 880 } 898 881 -
uspace/lib/ui/test/wdecor.c
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2023 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>37 36 #include <ui/wdecor.h> 38 37 #include "../private/wdecor.h" … … 1323 1322 PCUT_TEST(rect_from_app) 1324 1323 { 1325 errno_t rc;1326 ui_t *ui = NULL;1327 1324 gfx_rect_t arect; 1328 1325 gfx_rect_t rect; 1329 1330 rc = ui_create_disp(NULL, &ui);1331 PCUT_ASSERT_ERRNO_VAL(EOK, rc);1332 1326 1333 1327 arect.p0.x = 14; … … 1336 1330 arect.p1.y = 196; 1337 1331 1338 ui_wdecor_rect_from_app(ui , ui_wds_none, &arect, &rect);1332 ui_wdecor_rect_from_app(ui_wds_none, &arect, &rect); 1339 1333 1340 1334 PCUT_ASSERT_INT_EQUALS(14, rect.p0.x); … … 1343 1337 PCUT_ASSERT_INT_EQUALS(196, rect.p1.y); 1344 1338 1345 ui_wdecor_rect_from_app(ui , ui_wds_frame, &arect, &rect);1339 ui_wdecor_rect_from_app(ui_wds_frame, &arect, &rect); 1346 1340 1347 1341 PCUT_ASSERT_INT_EQUALS(10, rect.p0.x); … … 1350 1344 PCUT_ASSERT_INT_EQUALS(200, rect.p1.y); 1351 1345 1352 ui_wdecor_rect_from_app(ui , ui_wds_decorated, &arect, &rect);1346 ui_wdecor_rect_from_app(ui_wds_decorated, &arect, &rect); 1353 1347 1354 1348 PCUT_ASSERT_INT_EQUALS(10, rect.p0.x); … … 1357 1351 PCUT_ASSERT_INT_EQUALS(200, rect.p1.y); 1358 1352 1359 ui_destroy(ui);1360 1353 } 1361 1354 -
uspace/lib/usbhid/src/hidparser.c
rc37c24c r6c1e7c0 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( (unsigned)bits, 8 - bit_offset);227 const int lsb_bits = min(bits, 8); 228 228 229 229 value |= (*data >> bit_offset) & BIT_RRANGE(uint8_t, lsb_bits); -
uspace/srv/hid/output/port/ega.c
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2021 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 = 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); 92 attr = (attrs.val.rgb.bgcolor < attrs.val.rgb.fgcolor) ? 93 ega.style_inverted : ega.style_normal; 99 94 break; 100 95 } -
uspace/srv/locsrv/locsrv.c
rc37c24c r6c1e7c0 1 1 /* 2 * Copyright (c) 2024 Jiri Svoboda3 2 * Copyright (c) 2007 Josef Cejka 3 * Copyright (c) 2011 Jiri Svoboda 4 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 1359 1356 cat = category_new("test3"); 1360 1357 categ_dir_add_cat(&cdir, cat); -
version
rc37c24c r6c1e7c0 28 28 29 29 30 HELENOS_RELEASE = 0.1 4.131 HELENOS_CODENAME = Aladar32 HELENOS_COPYRIGHT = Copyright (c) 2001-202 4HelenOS project30 HELENOS_RELEASE = 0.12.1 31 HELENOS_CODENAME = Cathode 32 HELENOS_COPYRIGHT = Copyright (c) 2001-2022 HelenOS project
Note:
See TracChangeset
for help on using the changeset viewer.