Changeset dc5c303 in mainline for uspace/app


Ignore:
Timestamp:
2023-12-28T13:59:23Z (2 years ago)
Author:
GitHub <noreply@…>
Children:
6b66de6b
Parents:
42c2e65 (diff), f87ff8e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
boba-buba <120932204+boba-buba@…> (2023-12-28 13:59:23)
git-committer:
GitHub <noreply@…> (2023-12-28 13:59:23)
Message:

Merge branch 'master' into topic/packet-capture

Location:
uspace/app
Files:
39 added
43 edited
2 moved

Legend:

Unmodified
Added
Removed
  • uspace/app/calculator/calculator.c

    r42c2e65 rdc5c303  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * Copyright (c) 2016 Martin Decky
    44 * All rights reserved.
     
    4646#include <ui/entry.h>
    4747#include <ui/fixed.h>
     48#include <ui/menu.h>
    4849#include <ui/menubar.h>
    49 #include <ui/menu.h>
     50#include <ui/menudd.h>
    5051#include <ui/menuentry.h>
    5152#include <ui/pbutton.h>
     
    896897        }
    897898
    898         rc = ui_menu_create(calc.menubar, "~F~ile", &mfile);
     899        rc = ui_menu_dd_create(calc.menubar, "~F~ile", NULL, &mfile);
    899900        if (rc != EOK) {
    900901                printf("Error creating menu.\n");
     
    910911        ui_menu_entry_set_cb(mexit, calc_file_exit, (void *) &calc);
    911912
    912         rc = ui_menu_create(calc.menubar, "~E~dit", &medit);
     913        rc = ui_menu_dd_create(calc.menubar, "~E~dit", NULL, &medit);
    913914        if (rc != EOK) {
    914915                printf("Error creating menu.\n");
  • uspace/app/corecfg/meson.build

    r42c2e65 rdc5c303  
    11#
    2 # Copyright (c) 2013 Jiri Svoboda
     2# Copyright (c) 2023 Jiri Svoboda
    33# All rights reserved.
    44#
     
    2727#
    2828
     29deps = [ 'corecfg' ]
    2930src = files('corecfg.c')
  • uspace/app/disp/disp.c

    r42c2e65 rdc5c303  
    5656        printf("  %s assign-dev <device> <seat>\n", NAME);
    5757        printf("  %s unassign-dev <device>\n", NAME);
     58        printf("  %s list-dev <seat>\n", NAME);
    5859}
    5960
     
    393394}
    394395
     396/** List dev subcommand.
     397 *
     398 * @param dcfg_svc Display configuration service name
     399 * @param argc Number of arguments
     400 * @param argv Arguments
     401 * @return EOK on success or an erro code
     402 */
     403static errno_t list_dev(const char *dcfg_svc, int argc, char *argv[])
     404{
     405        dispcfg_t *dispcfg;
     406        char *seat_name;
     407        sysarg_t seat_id;
     408        dispcfg_dev_list_t *dev_list;
     409        size_t i;
     410        char *svc_name;
     411        table_t *table = NULL;
     412        errno_t rc;
     413
     414        if (argc < 1) {
     415                printf(NAME ": Missing arguments.\n");
     416                print_syntax();
     417                return EINVAL;
     418        }
     419
     420        if (argc > 1) {
     421                printf(NAME ": Too many arguments.\n");
     422                print_syntax();
     423                return EINVAL;
     424        }
     425
     426        seat_name = argv[0];
     427
     428        rc = dispcfg_open(dcfg_svc, NULL, NULL, &dispcfg);
     429        if (rc != EOK) {
     430                printf(NAME ": Failed connecting to display configuration "
     431                    "service: %s.\n", str_error(rc));
     432                return rc;
     433        }
     434
     435        rc = seat_find_by_name(dispcfg, seat_name, &seat_id);
     436        if (rc != EOK) {
     437                printf(NAME ": Seat '%s' not found.\n", seat_name);
     438                dispcfg_close(dispcfg);
     439                return ENOENT;
     440        }
     441
     442        rc = dispcfg_get_asgn_dev_list(dispcfg, seat_id, &dev_list);
     443        if (rc != EOK) {
     444                printf(NAME ": Failed getting seat list.\n");
     445                dispcfg_close(dispcfg);
     446                return rc;
     447        }
     448
     449        rc = table_create(&table);
     450        if (rc != EOK) {
     451                printf("Memory allocation failed.\n");
     452                dispcfg_free_dev_list(dev_list);
     453                dispcfg_close(dispcfg);
     454                return rc;
     455        }
     456
     457        table_header_row(table);
     458        table_printf(table, "Device Name\n");
     459
     460        for (i = 0; i < dev_list->ndevs; i++) {
     461                rc = loc_service_get_name(dev_list->devs[i], &svc_name);
     462                if (rc != EOK) {
     463                        printf("Failed getting name of service %zu\n",
     464                            (size_t)dev_list->devs[i]);
     465                        continue;
     466                }
     467
     468                table_printf(table, "%s\n", svc_name);
     469                free(svc_name);
     470        }
     471
     472        if (dev_list->ndevs != 0) {
     473                rc = table_print_out(table, stdout);
     474                if (rc != EOK) {
     475                        printf("Error printing table.\n");
     476                        table_destroy(table);
     477                        dispcfg_free_dev_list(dev_list);
     478                        dispcfg_close(dispcfg);
     479                        return rc;
     480                }
     481        }
     482
     483        dispcfg_close(dispcfg);
     484        return EOK;
     485}
     486
    395487int main(int argc, char *argv[])
    396488{
     
    423515                if (rc != EOK)
    424516                        return 1;
     517        } else if (str_cmp(argv[1], "list-dev") == 0) {
     518                rc = list_dev(dispcfg_svc, argc - 2, argv + 2);
     519                if (rc != EOK)
     520                        return 1;
    425521        } else {
    426522                printf(NAME ": Unknown command '%s'.\n", argv[1]);
  • uspace/app/edit/edit.c

    r42c2e65 rdc5c303  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * Copyright (c) 2012 Martin Sucha
    44 * All rights reserved.
     
    6060#include <ui/menu.h>
    6161#include <ui/menubar.h>
     62#include <ui/menudd.h>
    6263#include <ui/menuentry.h>
    6364#include <ui/promptdialog.h>
     
    430431        }
    431432
    432         rc = ui_menu_create(edit->menubar, "~F~ile", &mfile);
     433        rc = ui_menu_dd_create(edit->menubar, "~F~ile", NULL, &mfile);
    433434        if (rc != EOK) {
    434435                printf("Error creating menu.\n");
     
    466467        ui_menu_entry_set_cb(mexit, edit_file_exit, (void *) edit);
    467468
    468         rc = ui_menu_create(edit->menubar, "~E~dit", &medit);
     469        rc = ui_menu_dd_create(edit->menubar, "~E~dit", NULL, &medit);
    469470        if (rc != EOK) {
    470471                printf("Error creating menu.\n");
     
    518519        ui_menu_entry_set_cb(mselall, edit_edit_select_all, (void *) edit);
    519520
    520         rc = ui_menu_create(edit->menubar, "~S~earch", &msearch);
     521        rc = ui_menu_dd_create(edit->menubar, "~S~earch", NULL, &msearch);
    521522        if (rc != EOK) {
    522523                printf("Error creating menu.\n");
  • uspace/app/gfxdemo/gfxdemo.c

    r42c2e65 rdc5c303  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    5151#include <ui/window.h>
    5252#include <ui/wdecor.h>
     53#include "gfxdemo.h"
    5354
    5455static void wnd_close_event(void *);
     
    6869};
    6970
     71static void demo_kbd_event(kbd_event_t *);
     72
    7073static bool quit = false;
     74static FIBRIL_MUTEX_INITIALIZE(quit_lock);
     75static FIBRIL_CONDVAR_INITIALIZE(quit_cv);
    7176static gfx_typeface_t *tface;
    7277static gfx_font_t *font;
    7378static gfx_coord_t vpad;
     79static console_ctrl_t *con = NULL;
     80static ui_t *ui;
    7481
    7582/** Determine if we are running in text mode.
     
    8390        // XXX Need a proper way to determine text mode
    8491        return w <= 80;
     92}
     93
     94/** Sleep until timeout or quit request.
     95 *
     96 * @param msec Number of microseconds to sleep for
     97 */
     98static void demo_msleep(unsigned msec)
     99{
     100        errno_t rc;
     101        usec_t usec;
     102        cons_event_t cevent;
     103
     104        if (ui != NULL)
     105                ui_unlock(ui);
     106        fibril_mutex_lock(&quit_lock);
     107        if (!quit) {
     108                if (con != NULL) {
     109                        usec = (usec_t)msec * 1000;
     110                        while (usec > 0 && !quit) {
     111                                rc = console_get_event_timeout(con, &cevent, &usec);
     112                                if (rc == EOK) {
     113                                        if (cevent.type == CEV_KEY) {
     114                                                fibril_mutex_unlock(&quit_lock);
     115                                                demo_kbd_event(&cevent.ev.key);
     116                                                fibril_mutex_lock(&quit_lock);
     117                                        }
     118                                }
     119                        }
     120                } else {
     121                        (void) fibril_condvar_wait_timeout(&quit_cv, &quit_lock,
     122                            (usec_t)msec * 1000);
     123                }
     124        }
     125        fibril_mutex_unlock(&quit_lock);
     126        if (ui != NULL)
     127                ui_lock(ui);
    85128}
    86129
     
    316359                gfx_color_delete(color);
    317360
    318                 fibril_usleep(500 * 1000);
    319 
     361                demo_msleep(500);
    320362                if (quit)
    321363                        break;
     
    478520                        if (rc != EOK)
    479521                                goto error;
    480                         fibril_usleep(250 * 1000);
    481 
     522
     523                        demo_msleep(250);
    482524                        if (quit)
    483525                                goto out;
     
    539581                }
    540582
    541                 fibril_usleep(500 * 1000);
    542 
     583                demo_msleep(500);
    543584                if (quit)
    544585                        break;
     
    600641                }
    601642
    602                 fibril_usleep(500 * 1000);
    603 
     643                demo_msleep(500);
    604644                if (quit)
    605645                        break;
     
    791831
    792832        for (i = 0; i < 10; i++) {
    793                 fibril_usleep(500 * 1000);
     833                demo_msleep(500);
    794834                if (quit)
    795835                        break;
     
    872912
    873913        for (i = 0; i < 10; i++) {
    874                 fibril_usleep(500 * 1000);
     914                demo_msleep(500);
    875915                if (quit)
    876916                        break;
     
    9691009                }
    9701010
    971                 fibril_usleep(500 * 1000);
    972 
     1011                demo_msleep(500);
    9731012                if (quit)
    9741013                        break;
     
    10361075static errno_t demo_console(void)
    10371076{
    1038         console_ctrl_t *con = NULL;
    10391077        console_gc_t *cgc = NULL;
    10401078        gfx_context_t *gc;
    1041         errno_t rc;
    1042 
    1043         printf("Init console..\n");
     1079        sysarg_t cols, rows;
     1080        errno_t rc;
     1081
    10441082        con = console_init(stdin, stdout);
    10451083        if (con == NULL)
    10461084                return EIO;
    10471085
    1048         printf("Create console GC\n");
     1086        rc = console_get_size(con, &cols, &rows);
     1087        if (rc != EOK)
     1088                return rc;
     1089
    10491090        rc = console_gc_create(con, stdout, &cgc);
    10501091        if (rc != EOK)
     
    10531094        gc = console_gc_get_ctx(cgc);
    10541095
    1055         rc = demo_loop(gc, 80, 25);
     1096        rc = demo_loop(gc, cols, rows);
    10561097        if (rc != EOK)
    10571098                return rc;
     
    10621103
    10631104        return EOK;
     1105}
     1106
     1107static errno_t demo_ui_fibril(void *arg)
     1108{
     1109        demo_ui_args_t *args = (demo_ui_args_t *)arg;
     1110        errno_t rc;
     1111
     1112        ui_lock(args->ui);
     1113        rc = demo_loop(args->gc, args->dims.x, args->dims.y);
     1114        ui_unlock(args->ui);
     1115        ui_quit(args->ui);
     1116        return rc;
    10641117}
    10651118
     
    10671120static errno_t demo_ui(const char *display_spec)
    10681121{
    1069         ui_t *ui = NULL;
    10701122        ui_wnd_params_t params;
    10711123        ui_window_t *window = NULL;
     
    10741126        gfx_rect_t wrect;
    10751127        gfx_coord2_t off;
    1076         errno_t rc;
    1077 
    1078         printf("Init UI..\n");
     1128        gfx_rect_t ui_rect;
     1129        gfx_coord2_t dims;
     1130        demo_ui_args_t args;
     1131        fid_t fid;
     1132        errno_t rc;
    10791133
    10801134        rc = ui_create(display_spec, &ui);
    10811135        if (rc != EOK) {
    10821136                printf("Error initializing UI (%s)\n", display_spec);
     1137                goto error;
     1138        }
     1139
     1140        rc = ui_get_rect(ui, &ui_rect);
     1141        if (rc != EOK) {
     1142                printf("Error getting display size.\n");
    10831143                goto error;
    10841144        }
     
    10911151        ui_wnd_params_init(&params);
    10921152        params.caption = "GFX Demo";
     1153
     1154        /* Do not decorate the window in fullscreen mode */
     1155        if (ui_is_fullscreen(ui))
     1156                params.style &= ~ui_wds_decorated;
    10931157
    10941158        /*
     
    11001164        gfx_rect_rtranslate(&off, &wrect, &params.rect);
    11011165
     1166        gfx_rect_dims(&ui_rect, &dims);
     1167
     1168        /* Make sure window is not larger than the entire screen */
     1169        if (params.rect.p1.x > dims.x)
     1170                params.rect.p1.x = dims.x;
     1171        if (params.rect.p1.y > dims.y)
     1172                params.rect.p1.y = dims.y;
     1173
    11021174        rc = ui_window_create(ui, &params, &window);
    11031175        if (rc != EOK) {
     
    11141186        }
    11151187
    1116         task_retval(0);
    1117 
    1118         rc = demo_loop(gc, rect.p1.x, rect.p1.y);
    1119         if (rc != EOK)
    1120                 goto error;
    1121 
     1188        ui_window_get_app_rect(window, &rect);
     1189        gfx_rect_dims(&rect, &dims);
     1190
     1191        if (!ui_is_fullscreen(ui))
     1192                task_retval(0);
     1193
     1194        args.gc = gc;
     1195        args.dims = dims;
     1196        args.ui = ui;
     1197
     1198        fid = fibril_create(demo_ui_fibril, (void *)&args);
     1199        if (fid == 0) {
     1200                rc = ENOMEM;
     1201                goto error;
     1202        }
     1203
     1204        fibril_add_ready(fid);
     1205
     1206        ui_run(ui);
    11221207        ui_window_destroy(window);
    11231208        ui_destroy(ui);
     
    11411226        errno_t rc;
    11421227
    1143         printf("Init display..\n");
    1144 
    11451228        rc = display_open(display_svc, &display);
    11461229        if (rc != EOK) {
     
    11841267}
    11851268
     1269static void demo_quit(void)
     1270{
     1271        fibril_mutex_lock(&quit_lock);
     1272        quit = true;
     1273        fibril_mutex_unlock(&quit_lock);
     1274        fibril_condvar_broadcast(&quit_cv);
     1275}
     1276
    11861277static void wnd_close_event(void *arg)
    11871278{
    1188         printf("Close event\n");
    1189         quit = true;
     1279        demo_quit();
     1280}
     1281
     1282static void demo_kbd_event(kbd_event_t *event)
     1283{
     1284        if (event->type == KEY_PRESS) {
     1285                /* Ctrl-Q */
     1286                if ((event->mods & KM_CTRL) != 0 &&
     1287                    (event->mods & KM_ALT) == 0 &&
     1288                    (event->mods & KM_SHIFT) == 0 &&
     1289                    event->key == KC_Q) {
     1290                        demo_quit();
     1291                }
     1292
     1293                /* Escape */
     1294                if ((event->mods & KM_CTRL) == 0 &&
     1295                    (event->mods & KM_ALT) == 0 &&
     1296                    (event->mods & KM_SHIFT) == 0 &&
     1297                    event->key == KC_ESCAPE) {
     1298                        demo_quit();
     1299                }
     1300        }
    11901301}
    11911302
    11921303static void wnd_kbd_event(void *arg, kbd_event_t *event)
    11931304{
    1194         printf("Keyboard event type=%d key=%d\n", event->type, event->key);
    1195         if (event->type == KEY_PRESS)
    1196                 quit = true;
     1305        (void)arg;
     1306        demo_kbd_event(event);
    11971307}
    11981308
    11991309static void uiwnd_close_event(ui_window_t *window, void *arg)
    12001310{
    1201         printf("Close event\n");
    1202         quit = true;
     1311        demo_quit();
    12031312}
    12041313
    12051314static void uiwnd_kbd_event(ui_window_t *window, void *arg, kbd_event_t *event)
    12061315{
    1207         printf("Keyboard event type=%d key=%d\n", event->type, event->key);
    1208         if (event->type == KEY_PRESS)
    1209                 quit = true;
     1316        (void)window;
     1317        (void)arg;
     1318        demo_kbd_event(event);
    12101319}
    12111320
     
    12191328        errno_t rc;
    12201329        const char *display_svc = DISPLAY_DEFAULT;
    1221         const char *ui_display_spec = UI_DISPLAY_DEFAULT;
     1330        const char *ui_display_spec = UI_ANY_DEFAULT;
    12221331        int i;
    12231332
  • uspace/app/hbench/benchlist.c

    r42c2e65 rdc5c303  
    11/*
    2  * Copyright (c) 2018 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * Copyright (c) 2018 Vojtech Horky
    44 * All rights reserved.
     
    4545        &benchmark_malloc2,
    4646        &benchmark_ns_ping,
    47         &benchmark_ping_pong
     47        &benchmark_ping_pong,
     48        &benchmark_read1k,
     49        &benchmark_taskgetid,
     50        &benchmark_write1k,
    4851};
    4952
  • uspace/app/hbench/env.c

    r42c2e65 rdc5c303  
    9797
    9898        env->run_count = DEFAULT_RUN_COUNT;
    99         env->minimal_run_duration_nanos = MSEC2NSEC(DEFAULT_MIN_RUN_DURATION_SEC);
     99        env->minimal_run_duration_nanos = MSEC2NSEC(DEFAULT_MIN_RUN_DURATION_MSEC);
    100100
    101101        return EOK;
  • uspace/app/hbench/hbench.h

    r42c2e65 rdc5c303  
    11/*
    2  * Copyright (c) 2018 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * Copyright (c) 2019 Vojtech Horky
    44 * All rights reserved.
     
    4343
    4444#define DEFAULT_RUN_COUNT 10
    45 #define DEFAULT_MIN_RUN_DURATION_SEC 10
     45#define DEFAULT_MIN_RUN_DURATION_MSEC 1000
    4646
    4747/** Single run information.
     
    139139extern benchmark_t benchmark_ns_ping;
    140140extern benchmark_t benchmark_ping_pong;
     141extern benchmark_t benchmark_read1k;
     142extern benchmark_t benchmark_taskgetid;
     143extern benchmark_t benchmark_write1k;
    141144
    142145#endif
  • uspace/app/hbench/meson.build

    r42c2e65 rdc5c303  
    11#
    2 # Copyright (c) 2018 Jiri Svoboda
     2# Copyright (c) 2023 Jiri Svoboda
    33# All rights reserved.
    44#
     
    2727#
    2828
    29 deps = [ 'math' ]
     29deps = [ 'math', 'ipctest' ]
    3030src = files(
    3131        'benchlist.c',
     
    3838        'ipc/ns_ping.c',
    3939        'ipc/ping_pong.c',
     40        'ipc/read1k.c',
     41        'ipc/write1k.c',
    4042        'malloc/malloc1.c',
    4143        'malloc/malloc2.c',
    4244        'synch/fibril_mutex.c',
     45        'syscall/taskgetid.c'
    4346)
  • uspace/app/meson.build

    r42c2e65 rdc5c303  
    4040        'df',
    4141        'disp',
     42        'display-cfg',
    4243        'dnscfg',
    4344        'dnsres',
     
    7273        'nterm',
    7374        'pcapctl',
     75        'ofw',
    7476        'pci',
    7577        'ping',
     
    8284        'sysinst',
    8385        'taskbar',
     86        'taskbar-cfg',
    8487        'taskdump',
    8588        'terminal',
  • uspace/app/mkbd/meson.build

    r42c2e65 rdc5c303  
    2727#
    2828
    29 deps = [ 'usb', 'usbdev', 'usbhid', 'drv' ]
     29deps = [ 'usb', 'usbdev', 'usbhid', 'drv', 'console' ]
    3030src = files('main.c')
  • uspace/app/modplay/meson.build

    r42c2e65 rdc5c303  
    2727#
    2828
    29 deps = [ 'trackmod', 'hound', 'pcm' ]
     29deps = [ 'trackmod', 'hound', 'pcm', 'console' ]
    3030src = files('modplay.c')
    3131
  • uspace/app/nav/menu.c

    r42c2e65 rdc5c303  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3939#include <ui/menu.h>
    4040#include <ui/menubar.h>
     41#include <ui/menudd.h>
    4142#include <ui/menuentry.h>
    4243#include "menu.h"
     
    7273                goto error;
    7374
    74         rc = ui_menu_create(menu->menubar, "~F~ile", &mfile);
     75        rc = ui_menu_dd_create(menu->menubar, "~F~ile", NULL, &mfile);
    7576        if (rc != EOK)
    7677                goto error;
  • uspace/app/netecho/meson.build

    r42c2e65 rdc5c303  
    2727#
    2828
    29 deps = [ 'inet' ]
     29deps = [ 'inet', 'console' ]
    3030src = files('comm.c', 'netecho.c')
  • uspace/app/nterm/meson.build

    r42c2e65 rdc5c303  
    2727#
    2828
    29 deps = [ 'inet' ]
     29deps = [ 'inet', 'console' ]
    3030src = files('conn.c', 'nterm.c')
  • uspace/app/ping/meson.build

    r42c2e65 rdc5c303  
    2727#
    2828
    29 deps = [ 'inet' ]
     29deps = [ 'inet', 'console' ]
    3030src = files('ping.c')
  • uspace/app/taskbar-cfg/smeedit.h

    r42c2e65 rdc5c303  
    11/*
    2  * Copyright (c) 2006 Ondrej Palkovsky
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup kernel_generic_mm
     29/** @addtogroup taskbar-cfg
    3030 * @{
    3131 */
    32 /** @file
     32/**
     33 * @file Start menu entry edit dialog
    3334 */
    3435
    35 #ifndef KERN_STDLIB_H_
    36 #define KERN_STDLIB_H_
     36#ifndef SMEEDIT_H
     37#define SMEEDIT_H
    3738
    38 #include <stddef.h>
     39#include "types/smeedit.h"
     40#include "types/startmenu.h"
    3941
    40 extern void *malloc(size_t)
    41     __attribute__((malloc));
    42 extern void *realloc(void *, size_t)
    43     __attribute__((warn_unused_result));
    44 extern void free(void *);
     42extern errno_t smeedit_create(startmenu_t *, startmenu_entry_t *, smeedit_t **);
     43extern void smeedit_destroy(smeedit_t *);
    4544
    4645#endif
  • uspace/app/taskbar-cfg/types/smeedit.h

    r42c2e65 rdc5c303  
    11/*
    2  * Copyright (c) 2001-2004 Jakub Jermar
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup kernel_generic
     29/** @addtogroup taskbar-cfg
    3030 * @{
    3131 */
    32 /** @file
     32/**
     33 * @file Start menu entry edit dialog
    3334 */
    3435
    35 #ifndef KERN_MEM_H_
    36 #define KERN_MEM_H_
     36#ifndef TYPES_SMEEDIT_H
     37#define TYPES_SMEEDIT_H
    3738
    38 #include <stddef.h>
    39 #include <stdint.h>
    40 #include <cc.h>
     39#include <ui/fixed.h>
     40#include <ui/label.h>
     41#include <ui/entry.h>
     42#include <ui/pbutton.h>
     43#include <ui/window.h>
    4144
    42 #ifdef CONFIG_LTO
    43 #define DO_NOT_DISCARD ATTRIBUTE_USED
    44 #else
    45 #define DO_NOT_DISCARD
    46 #endif
    47 
    48 #define memset(dst, val, cnt)  __builtin_memset((dst), (val), (cnt))
    49 #define memcpy(dst, src, cnt)  __builtin_memcpy((dst), (src), (cnt))
    50 #define memcmp(s1, s2, cnt)    __builtin_memcmp((s1), (s2), (cnt))
    51 
    52 extern void memsetb(void *, size_t, uint8_t)
    53     __attribute__((nonnull(1)));
    54 extern void memsetw(void *, size_t, uint16_t)
    55     __attribute__((nonnull(1)));
    56 extern void *memmove(void *, const void *, size_t)
    57     __attribute__((nonnull(1, 2))) DO_NOT_DISCARD;
     45/** Start menu entry edit dialog */
     46typedef struct smeedit {
     47        /** Containing start menu configuration tab */
     48        struct startmenu *startmenu;
     49        /** Start menu entry or @c NULL if creating a new entry */
     50        struct startmenu_entry *smentry;
     51        /** Window */
     52        ui_window_t *window;
     53        /** Fixed layout */
     54        ui_fixed_t *fixed;
     55        /** 'Caption' label */
     56        ui_label_t *lcaption;
     57        /** Caption entry */
     58        ui_entry_t *ecaption;
     59        /** 'Command' label */
     60        ui_label_t *lcmd;
     61        /** Command entry */
     62        ui_entry_t *ecmd;
     63        /** OK buttion */
     64        ui_pbutton_t *bok;
     65        /** Cancel button */
     66        ui_pbutton_t *bcancel;
     67} smeedit_t;
    5868
    5969#endif
  • uspace/app/taskbar/clock.c

    r42c2e65 rdc5c303  
    3030 * @{
    3131 */
    32 /** @file Task bar clock.
     32/** @file Taskbar clock.
    3333 *
    3434 * Displays the current time in an inset frame.
     
    5353static void taskbar_clock_timer(void *);
    5454
    55 /** Task bar clock control ops */
     55/** Taskbar clock control ops */
    5656static ui_control_ops_t taskbar_clock_ctl_ops = {
    5757        .destroy = taskbar_clock_ctl_destroy,
     
    6161};
    6262
    63 /** Create task bar clock.
     63/** Create taskbar clock.
    6464 *
    6565 * @param window Containing window
     
    102102}
    103103
    104 /** Destroy task bar clock.
    105  *
    106  * @param clock Task bar clock
     104/** Destroy taskbar clock.
     105 *
     106 * @param clock Taskbar clock
    107107 */
    108108void taskbar_clock_destroy(taskbar_clock_t *clock)
     
    149149}
    150150
    151 /** Paint task bar clock.
    152  *
    153  * @param clock Task bar clock
     151/** Paint taskbar clock.
     152 *
     153 * @param clock Taskbar clock
    154154 */
    155155errno_t taskbar_clock_paint(taskbar_clock_t *clock)
     
    208208}
    209209
    210 /** Handle task bar clock keyboard event.
    211  *
    212  * @param clock Task bar clock
     210/** Handle taskbar clock keyboard event.
     211 *
     212 * @param clock Taskbar clock
    213213 * @param event Keyboard event
    214214 * @return ui_claimed iff event was claimed
     
    219219}
    220220
    221 /** Handle task bar clock position event.
    222  *
    223  * @param clock Task bar clock
     221/** Handle taskbar clock position event.
     222 *
     223 * @param clock Taskbar clock
    224224 * @param event Position event
    225225 * @return ui_claimed iff event was claimed
     
    237237}
    238238
    239 /** Get base control for task bar clock.
    240  *
    241  * @param clock Task bar clock
     239/** Get base control for taskbar clock.
     240 *
     241 * @param clock Taskbar clock
    242242 * @return Base UI control
    243243 */
     
    247247}
    248248
    249 /** Set task bar clock rectangle.
    250  *
    251  * @param clock Task bar clock
     249/** Set taskbar clock rectangle.
     250 *
     251 * @param clock Taskbar clock
    252252 * @param rect Rectangle
    253253 */
     
    277277}
    278278
    279 /** Paint task bar clock control.
     279/** Paint taskbar clock control.
    280280 *
    281281 * @param arg Argument (taskbar_clock_t *)
     
    289289}
    290290
    291 /** Handle task bar clock control keyboard event.
     291/** Handle taskbar clock control keyboard event.
    292292 *
    293293 * @param arg Argument (taskbar_clock_t *)
     
    302302}
    303303
    304 /** Handle task bar clock control position event.
     304/** Handle taskbar clock control position event.
    305305 *
    306306 * @param arg Argument (taskbar_clock_t *)
     
    322322{
    323323        taskbar_clock_t *clock = (taskbar_clock_t *) arg;
     324        ui_t *ui;
     325
     326        ui = ui_window_get_ui(clock->window);
     327        ui_lock(ui);
    324328
    325329        fibril_mutex_lock(&clock->lock);
    326         (void) taskbar_clock_paint(clock);
     330        if (!ui_is_suspended(ui_window_get_ui(clock->window)))
     331                (void) taskbar_clock_paint(clock);
    327332
    328333        if (!clock->timer_cleanup) {
     
    336341
    337342        fibril_mutex_unlock(&clock->lock);
     343        ui_unlock(ui);
    338344}
    339345
  • uspace/app/taskbar/clock.h

    r42c2e65 rdc5c303  
    3131 */
    3232/**
    33  * @file Task bar clock
     33 * @file Taskbar clock
    3434 */
    3535
  • uspace/app/taskbar/doc/doxygroups.h

    r42c2e65 rdc5c303  
    11/** @addtogroup taskbar taskbar
    2  * @brief Task bar
     2 * @brief Taskbar
    33 * @ingroup apps
    44 */
  • uspace/app/taskbar/main.c

    r42c2e65 rdc5c303  
    3030 * @{
    3131 */
    32 /** @file Task Bar
     32/** @file Taskbar
    3333 */
    3434
  • uspace/app/taskbar/meson.build

    r42c2e65 rdc5c303  
    11#
    2 # Copyright (c) 2022 Jiri Svoboda
     2# Copyright (c) 2023 Jiri Svoboda
    33# All rights reserved.
    44#
     
    2727#
    2828
    29 deps = [ 'ui', 'wndmgt' ]
     29deps = [ 'tbarcfg', 'ui', 'wndmgt' ]
    3030src = files(
    3131        'clock.c',
    3232        'main.c',
    3333        'taskbar.c',
     34        'tbsmenu.c',
    3435        'wndlist.c',
    3536)
     
    3839        'clock.c',
    3940        'taskbar.c',
     41        'tbsmenu.c',
    4042        'wndlist.c',
    4143        'test/clock.c',
    4244        'test/main.c',
    4345        'test/taskbar.c',
     46        'test/tbsmenu.c',
    4447        'test/wndlist.c',
    4548)
     49
     50if install_nonessential_data
     51        installed_data += { 'name': 'taskbar.sif', 'dir': '/cfg' }
     52endif
  • uspace/app/taskbar/taskbar.c

    r42c2e65 rdc5c303  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3030 * @{
    3131 */
    32 /** @file Task Bar
     32/** @file Taskbar
    3333 */
    3434
     
    3939#include <str.h>
    4040#include <ui/fixed.h>
    41 #include <ui/label.h>
    4241#include <ui/resource.h>
    4342#include <ui/ui.h>
     
    4645#include "clock.h"
    4746#include "taskbar.h"
     47#include "tbsmenu.h"
    4848#include "wndlist.h"
    4949
    5050static void taskbar_wnd_close(ui_window_t *, void *);
     51static void taskbar_wnd_kbd(ui_window_t *, void *, kbd_event_t *);
    5152static void taskbar_wnd_pos(ui_window_t *, void *, pos_event_t *);
    5253
    5354static ui_window_cb_t window_cb = {
    5455        .close = taskbar_wnd_close,
     56        .kbd = taskbar_wnd_kbd,
    5557        .pos = taskbar_wnd_pos
    5658};
     
    6668
    6769        ui_quit(taskbar->ui);
     70}
     71
     72/** Window received keyboard event.
     73 *
     74 * @param window Window
     75 * @param arg Argument (taskbar)
     76 * @param event Keyboard event
     77 */
     78static void taskbar_wnd_kbd(ui_window_t *window, void *arg, kbd_event_t *event)
     79{
     80        taskbar_t *taskbar = (taskbar_t *) arg;
     81        ui_evclaim_t claim;
     82
     83        /* Remember ID of device that sent the last event */
     84        taskbar->wndlist->ev_idev_id = event->kbd_id;
     85        taskbar->tbsmenu->ev_idev_id = event->kbd_id;
     86
     87        claim = ui_window_def_kbd(window, event);
     88        if (claim == ui_claimed)
     89                return;
     90
     91        if (event->type == KEY_PRESS && (event->mods & KM_CTRL) == 0 &&
     92            (event->mods & KM_ALT) == 0 && (event->mods & KM_SHIFT) == 0 &&
     93            event->key == KC_ENTER) {
     94                if (!tbsmenu_is_open(taskbar->tbsmenu))
     95                        tbsmenu_open(taskbar->tbsmenu);
     96        }
    6897}
    6998
     
    79108
    80109        /* Remember ID of device that sent the last event */
    81         taskbar->wndlist->ev_pos_id = event->pos_id;
     110        taskbar->wndlist->ev_idev_id = event->pos_id;
     111        taskbar->tbsmenu->ev_idev_id = event->pos_id;
    82112
    83113        ui_window_def_pos(window, event);
    84114}
    85115
    86 /** Create task bar.
     116/** Create taskbar.
    87117 *
    88118 * @param display_spec Display specification
    89119 * @param wndmgt_svc Window management service (or WNDMGT_DEFAULT)
    90  * @param rtaskbar Place to store pointer to new task bar
     120 * @param rtaskbar Place to store pointer to new taskbar
    91121 * @return @c EOK on success or an error coe
    92122 */
     
    98128        gfx_rect_t scr_rect;
    99129        gfx_rect_t rect;
    100         ui_resource_t *ui_res;
    101130        errno_t rc;
    102131
     
    128157
    129158        ui_wnd_params_init(&params);
    130         params.caption = "Task Bar";
     159        params.caption = "Taskbar";
    131160        params.placement = ui_wnd_place_bottom_left;
    132161
     
    160189        }
    161190
    162         ui_window_set_cb(taskbar->window, &window_cb, (void *)taskbar);
    163         ui_res = ui_window_get_res(taskbar->window);
    164 
    165191        rc = ui_fixed_create(&taskbar->fixed);
    166192        if (rc != EOK) {
     
    169195        }
    170196
    171         rc = ui_label_create(ui_res, "HelenOS", &taskbar->label);
    172         if (rc != EOK) {
    173                 printf("Error creating label.\n");
    174                 goto error;
    175         }
    176 
    177         ui_window_get_app_rect(taskbar->window, &rect);
     197        rc = tbsmenu_create(taskbar->window, taskbar->fixed, &taskbar->tbsmenu);
     198        if (rc != EOK) {
     199                printf("Error creating start menu.\n");
     200                goto error;
     201        }
     202
     203        rc = tbsmenu_load(taskbar->tbsmenu, "/cfg/taskbar.sif");
     204        if (rc != EOK) {
     205                printf("Error loading start menu from '%s'.\n",
     206                    "/cfg/taskbar.sif");
     207        }
     208
    178209        if (ui_is_textmode(taskbar->ui)) {
    179                 rect.p0.x += 1;
     210                rect.p0.x = params.rect.p0.x + 1;
     211                rect.p0.y = 0;
     212                rect.p1.x = params.rect.p0.x + 9;
     213                rect.p1.y = 1;
    180214        } else {
    181                 rect.p0.x += 10;
    182         }
    183         ui_label_set_rect(taskbar->label, &rect);
    184         ui_label_set_halign(taskbar->label, gfx_halign_left);
    185         ui_label_set_valign(taskbar->label, gfx_valign_center);
    186 
    187         rc = ui_fixed_add(taskbar->fixed, ui_label_ctl(taskbar->label));
    188         if (rc != EOK) {
    189                 printf("Error adding control to layout.\n");
    190                 ui_label_destroy(taskbar->label);
    191                 goto error;
    192         }
     215                rect.p0.x = params.rect.p0.x + 5;
     216                rect.p0.y = 4;
     217                rect.p1.x = params.rect.p0.x + 84;
     218                rect.p1.y = 32 - 4;
     219        }
     220
     221        tbsmenu_set_rect(taskbar->tbsmenu, &rect);
    193222
    194223        rc = wndlist_create(taskbar->window, taskbar->fixed, &taskbar->wndlist);
     
    199228
    200229        if (ui_is_textmode(taskbar->ui)) {
    201                 rect.p0.x = params.rect.p0.x + 9;
     230                rect.p0.x = params.rect.p0.x + 10;
    202231                rect.p0.y = 0;
    203232                rect.p1.x = params.rect.p1.x - 10;
     
    211240        wndlist_set_rect(taskbar->wndlist, &rect);
    212241
     242        /*
     243         * We may not be able to open WM service if display server is not
     244         * running. That's okay, there simply are no windows to manage.
     245         */
    213246        rc = wndlist_open_wm(taskbar->wndlist, wndmgt_svc);
    214         if (rc != EOK) {
     247        if (rc != EOK && rc != ENOENT) {
    215248                printf("Error attaching window management service.\n");
    216249                goto error;
     
    243276
    244277        ui_window_add(taskbar->window, ui_fixed_ctl(taskbar->fixed));
     278        ui_window_set_cb(taskbar->window, &window_cb, (void *)taskbar);
    245279
    246280        rc = ui_window_paint(taskbar->window);
     
    257291        if (taskbar->wndlist != NULL)
    258292                wndlist_destroy(taskbar->wndlist);
     293        if (taskbar->tbsmenu != NULL)
     294                tbsmenu_destroy(taskbar->tbsmenu);
    259295        if (taskbar->window != NULL)
    260296                ui_window_destroy(taskbar->window);
     
    265301}
    266302
    267 /** Destroy task bar. */
     303/** Destroy taskbar. */
    268304void taskbar_destroy(taskbar_t *taskbar)
    269305{
    270306        ui_fixed_remove(taskbar->fixed, taskbar_clock_ctl(taskbar->clock));
    271307        taskbar_clock_destroy(taskbar->clock);
     308        wndlist_destroy(taskbar->wndlist);
     309        tbsmenu_destroy(taskbar->tbsmenu);
    272310        ui_window_destroy(taskbar->window);
    273311        ui_destroy(taskbar->ui);
  • uspace/app/taskbar/taskbar.h

    r42c2e65 rdc5c303  
    3131 */
    3232/**
    33  * @file Task Bar
     33 * @file Taskbar
    3434 */
    3535
  • uspace/app/taskbar/test/main.c

    r42c2e65 rdc5c303  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3333PCUT_IMPORT(clock);
    3434PCUT_IMPORT(taskbar);
     35PCUT_IMPORT(tbsmenu);
    3536PCUT_IMPORT(wndlist);
    3637
  • uspace/app/taskbar/test/wndlist.c

    r42c2e65 rdc5c303  
    139139        ui_fixed_t *fixed = NULL;
    140140        wndlist_t *wndlist;
     141        loc_srv_t *srv;
    141142
    142143        /* Set up a test WM service */
     
    145146
    146147        // FIXME This causes this test to be non-reentrant!
    147         rc = loc_server_register(test_wndmgt_server);
    148         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    149 
    150         rc = loc_service_register(test_wndmgt_svc, &sid);
     148        rc = loc_server_register(test_wndmgt_server, &srv);
     149        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     150
     151        rc = loc_service_register(srv, test_wndmgt_svc, &sid);
    151152        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    152153
     
    177178        ui_destroy(ui);
    178179
    179         rc = loc_service_unregister(sid);
    180         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     180        rc = loc_service_unregister(srv, sid);
     181        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     182        loc_server_unregister(srv);
    181183}
    182184
  • uspace/app/taskbar/types/clock.h

    r42c2e65 rdc5c303  
    3131 */
    3232/**
    33  * @file Task bar clock
     33 * @file Taskbar clock
    3434 */
    3535
     
    4141#include <ui/window.h>
    4242
    43 /** Task bar clock
     43/** Taskbar clock
    4444 *
    4545 * This is a custom UI control.
  • uspace/app/taskbar/types/taskbar.h

    r42c2e65 rdc5c303  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3131 */
    3232/**
    33  * @file Task Bar types
     33 * @file Taskbar types
    3434 */
    3535
     
    4343#include <ui/window.h>
    4444#include "clock.h"
     45#include "tbsmenu.h"
    4546#include "wndlist.h"
    4647
    47 /** Task bar */
     48/** Taskbar */
    4849typedef struct taskbar {
    4950        /** User interface */
     
    5354        /** Fixed layout */
    5455        ui_fixed_t *fixed;
    55         ui_label_t *label;
     56        /** Start menu */
     57        tbsmenu_t *tbsmenu;
    5658        /** Window list */
    5759        wndlist_t *wndlist;
  • uspace/app/taskbar/types/wndlist.h

    r42c2e65 rdc5c303  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3131 */
    3232/**
    33  * @file Task bar window list
     33 * @file Taskbar window list
    3434 */
    3535
     
    6161} wndlist_entry_t;
    6262
    63 /** Task bar window list */
     63/** Taskbar window list */
    6464typedef struct wndlist {
    6565        /** Base control object */
     
    6969        ui_window_t *window;
    7070
    71         /** Layout to which we add window buttoons */
     71        /** Layout to which we add window buttons */
    7272        ui_fixed_t *fixed;
    7373
     
    8484        wndmgt_t *wndmgt;
    8585
    86         /** Position ID of last position event */
    87         sysarg_t ev_pos_id;
     86        /** Device ID of last input event */
     87        sysarg_t ev_idev_id;
    8888} wndlist_t;
    8989
  • uspace/app/taskbar/wndlist.c

    r42c2e65 rdc5c303  
    3030 * @{
    3131 */
    32 /** @file Task bar window list
     32/** @file Taskbar window list
    3333 */
    3434
     
    4545#include <ui/ui.h>
    4646#include <ui/window.h>
    47 #include "clock.h"
    4847#include "wndlist.h"
    4948
     
    8180};
    8281
    83 /** Create task bar window list.
     82/** Create taskbar window list.
    8483 *
    8584 * @param window Containing window
    8685 * @param fixed Fixed layout to which buttons will be added
    87  * @param wndmgt Window management service
    8886 * @param rwndlist Place to store pointer to new window list
    8987 * @return @c EOK on success or an error code
     
    178176}
    179177
    180 /** Destroy task bar window list. */
     178/** Destroy taskbar window list.
     179 *
     180 * @param wndlist Window list
     181 */
    181182void wndlist_destroy(wndlist_t *wndlist)
    182183{
     
    253254                wndlist_set_entry_rect(wndlist, entry);
    254255                if (paint)
    255                         return ui_pbutton_paint(entry->button);
     256                        return wndlist_paint_entry(entry);
    256257        }
    257258
     
    319320                        wndlist_set_entry_rect(wndlist, e);
    320321                        if (paint) {
    321                                 rc = ui_pbutton_paint(e->button);
     322                                rc = wndlist_paint_entry(e);
    322323                                if (rc != EOK)
    323324                                        return rc;
     
    401402        ui_pbutton_set_light(entry->button, active);
    402403
    403         rc = ui_pbutton_paint(entry->button);
     404        rc = wndlist_paint_entry(entry);
    404405        if (rc != EOK)
    405406                return rc;
    406407
    407         return wndlist_repaint(wndlist);
     408        return EOK;
    408409}
    409410
     
    469470}
    470471
    471 /** Compute and set window list entry rectangle.
    472  *
    473  * Compute rectangle for window list entry and set it.
     472/** Paint window list entry.
    474473 *
    475474 * @param entry Window list entry
    476475 * @return EOK on success or an error code
    477476 */
     477errno_t wndlist_paint_entry(wndlist_entry_t *entry)
     478{
     479        ui_t *ui;
     480
     481        ui = ui_window_get_ui(entry->wndlist->window);
     482        if (ui_is_suspended(ui))
     483                return EOK;
     484
     485        return ui_pbutton_paint(entry->button);
     486}
     487
     488/** Unpaint window list entry.
     489 *
     490 * @param entry Window list entry
     491 * @return EOK on success or an error code
     492 */
    478493errno_t wndlist_unpaint_entry(wndlist_entry_t *entry)
    479494{
    480495        errno_t rc;
     496        ui_t *ui;
    481497        gfx_context_t *gc;
    482498        ui_resource_t *res;
    483499        gfx_color_t *color;
    484500
     501        ui = ui_window_get_ui(entry->wndlist->window);
    485502        gc = ui_window_get_gc(entry->wndlist->window);
    486503        res = ui_window_get_res(entry->wndlist->window);
    487504        color = ui_resource_get_wnd_face_color(res);
    488505
     506        if (ui_is_suspended(ui))
     507                return EOK;
     508
    489509        rc = gfx_set_color(gc, color);
    490510        if (rc != EOK)
     
    511531        wndlist_t *wndlist = (wndlist_t *)arg;
    512532        wndmgt_window_info_t *winfo = NULL;
     533        ui_t *ui;
    513534        errno_t rc;
     535
     536        ui = ui_window_get_ui(wndlist->window);
     537        ui_lock(ui);
    514538
    515539        rc = wndmgt_get_window_info(wndlist->wndmgt, wnd_id, &winfo);
     
    527551
    528552        wndmgt_free_window_info(winfo);
     553        ui_unlock(ui);
    529554        return;
    530555error:
    531556        if (winfo != NULL)
    532557                wndmgt_free_window_info(winfo);
     558        ui_unlock(ui);
    533559}
    534560
     
    542568        wndlist_t *wndlist = (wndlist_t *)arg;
    543569        wndlist_entry_t *entry;
     570        ui_t *ui;
     571
     572        ui = ui_window_get_ui(wndlist->window);
     573        ui_lock(ui);
    544574
    545575        entry = wndlist_entry_by_id(wndlist, wnd_id);
    546         if (entry == NULL)
     576        if (entry == NULL) {
     577                ui_unlock(ui);
    547578                return;
     579        }
    548580
    549581        (void) wndlist_remove(wndlist, entry, true);
     582        ui_unlock(ui);
    550583}
    551584
     
    560593        wndmgt_window_info_t *winfo = NULL;
    561594        wndlist_entry_t *entry;
     595        ui_t *ui;
    562596        errno_t rc;
    563597
     598        ui = ui_window_get_ui(wndlist->window);
     599        ui_lock(ui);
     600
    564601        entry = wndlist_entry_by_id(wndlist, wnd_id);
    565         if (entry == NULL)
     602        if (entry == NULL) {
     603                ui_unlock(ui);
    566604                return;
     605        }
    567606
    568607        rc = wndmgt_get_window_info(wndlist->wndmgt, wnd_id, &winfo);
    569         if (rc != EOK)
     608        if (rc != EOK) {
     609                ui_unlock(ui);
    570610                return;
     611        }
    571612
    572613        (void) wndlist_update(wndlist, entry, winfo->caption,
    573614            winfo->nfocus != 0);
    574615        wndmgt_free_window_info(winfo);
     616        ui_unlock(ui);
    575617}
    576618
     
    661703errno_t wndlist_repaint(wndlist_t *wndlist)
    662704{
     705        if (ui_is_suspended(ui_window_get_ui(wndlist->window)))
     706                return EOK;
     707
    663708        return ui_window_paint(wndlist->window);
    664709}
     
    675720
    676721        /* ID of device that clicked the button */
    677         dev_id = entry->wndlist->ev_pos_id;
     722        dev_id = entry->wndlist->ev_idev_id;
    678723
    679724        (void) wndmgt_activate_window(entry->wndlist->wndmgt,
  • uspace/app/taskbar/wndlist.h

    r42c2e65 rdc5c303  
    3131 */
    3232/**
    33  * @file Task bar window list
     33 * @file Taskbar window list
    3434 */
    3535
     
    6363extern size_t wndlist_count(wndlist_t *);
    6464extern errno_t wndlist_repaint(wndlist_t *);
     65extern errno_t wndlist_paint_entry(wndlist_entry_t *);
    6566extern errno_t wndlist_unpaint_entry(wndlist_entry_t *);
    6667
  • uspace/app/terminal/terminal.c

    r42c2e65 rdc5c303  
    10221022        term->srvs.sarg = term;
    10231023
    1024         rc = loc_server_register(NAME);
     1024        rc = loc_server_register(NAME, &term->srv);
    10251025        if (rc != EOK) {
    10261026                printf("Error registering server.\n");
     
    10331033            task_get_id());
    10341034
    1035         rc = loc_service_register(vc, &term->dsid);
     1035        rc = loc_service_register(term->srv, vc, &term->dsid);
    10361036        if (rc != EOK) {
    10371037                printf("Error registering service.\n");
     
    10631063        return EOK;
    10641064error:
     1065        if (term->dsid != 0)
     1066                loc_service_unregister(term->srv, term->dsid);
     1067        if (term->srv != NULL)
     1068                loc_server_unregister(term->srv);
    10651069        if (term->window != NULL)
    10661070                ui_window_destroy(term->window);
  • uspace/app/terminal/terminal.h

    r42c2e65 rdc5c303  
    11/*
    2  * Copyright (c) 2021 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * Copyright (c) 2012 Petr Koupy
    44 * All rights reserved.
     
    9191        charfield_t *ubuf;
    9292
     93        loc_srv_t *srv;
    9394        service_id_t dsid;
    9495        con_srvs_t srvs;
  • uspace/app/tester/fault/fault1.c

    r42c2e65 rdc5c303  
    3030#include "../tester.h"
    3131
     32#pragma GCC diagnostic ignored "-Warray-bounds"
     33
    3234const char *test_fault1(void)
    3335{
  • uspace/app/tester/meson.build

    r42c2e65 rdc5c303  
    11#
    2 # Copyright (c) 2021 Jiri Svoboda
     2# Copyright (c) 2023 Jiri Svoboda
    33# Copyright (c) 2005 Martin Decky
    44# Copyright (c) 2007 Jakub Jermar
     
    2929#
    3030
    31 deps = [ 'block', 'codepage', 'drv', 'math' ]
     31deps = [ 'block', 'codepage', 'drv', 'math', 'ipctest', 'console' ]
    3232src = files(
    3333        'tester.c',
     
    5252        'float/float2.c',
    5353        'vfs/vfs1.c',
     54        'ipc/readwrite.c',
    5455        'ipc/sharein.c',
    5556        'ipc/starve.c',
  • uspace/app/tester/mm/common.c

    r42c2e65 rdc5c303  
    3535#include <stdlib.h>
    3636#include <errno.h>
     37#include <malloc.h>
    3738#include "../tester.h"
    3839#include "common.h"
  • uspace/app/tester/print/print5.c

    r42c2e65 rdc5c303  
    3838 */
    3939#pragma GCC diagnostic ignored "-Wformat"
     40#pragma GCC diagnostic ignored "-Wformat-overflow"
    4041
    4142#include <stdio.h>
  • uspace/app/tester/tester.c

    r42c2e65 rdc5c303  
    6868#include "float/float2.def"
    6969#include "vfs/vfs1.def"
     70#include "ipc/readwrite.def"
    7071#include "ipc/sharein.def"
    7172#include "ipc/starve.def"
  • uspace/app/tester/tester.h

    r42c2e65 rdc5c303  
    9999extern const char *test_vfs1(void);
    100100extern const char *test_ping_pong(void);
     101extern const char *test_readwrite(void);
    101102extern const char *test_sharein(void);
    102103extern const char *test_starve_ipc(void);
  • uspace/app/tetris/meson.build

    r42c2e65 rdc5c303  
    2828#
    2929
     30deps = [ 'console' ]
    3031src = files(
    3132        'shapes.c',
  • uspace/app/top/meson.build

    r42c2e65 rdc5c303  
    2828#
    2929
     30deps = [ 'console' ]
    3031src = files(
    3132        'top.c',
  • uspace/app/trace/meson.build

    r42c2e65 rdc5c303  
    2828#
    2929
     30deps = [ 'console' ]
    3031src = files(
    3132        'trace.c',
  • uspace/app/uidemo/uidemo.c

    r42c2e65 rdc5c303  
    4545#include <ui/label.h>
    4646#include <ui/list.h>
     47#include <ui/menu.h>
    4748#include <ui/menubar.h>
     49#include <ui/menudd.h>
    4850#include <ui/menuentry.h>
    49 #include <ui/menu.h>
    5051#include <ui/msgdialog.h>
    5152#include <ui/pbutton.h>
    5253#include <ui/promptdialog.h>
    5354#include <ui/resource.h>
     55#include <ui/selectdialog.h>
    5456#include <ui/tab.h>
    5557#include <ui/tabset.h>
     
    108110static void uidemo_file_exit(ui_menu_entry_t *, void *);
    109111static void uidemo_edit_modify(ui_menu_entry_t *, void *);
     112static void uidemo_edit_insert_character(ui_menu_entry_t *, void *);
    110113
    111114static void file_dialog_bok(ui_file_dialog_t *, void *, const char *);
     
    127130        .bcancel = prompt_dialog_bcancel,
    128131        .close = prompt_dialog_close
     132};
     133
     134static void select_dialog_bok(ui_select_dialog_t *, void *, void *);
     135static void select_dialog_bcancel(ui_select_dialog_t *, void *);
     136static void select_dialog_close(ui_select_dialog_t *, void *);
     137
     138static ui_select_dialog_cb_t select_dialog_cb = {
     139        .bok = select_dialog_bok,
     140        .bcancel = select_dialog_bcancel,
     141        .close = select_dialog_close
    129142};
    130143
     
    275288        pos = ui_scrollbar_get_pos(scrollbar);
    276289        ui_scrollbar_set_pos(scrollbar, pos -
    277             ui_scrollbar_through_length(scrollbar) / 4);
     290            ui_scrollbar_trough_length(scrollbar) / 4);
    278291
    279292        pos = ui_scrollbar_get_pos(scrollbar);
     
    292305        pos = ui_scrollbar_get_pos(scrollbar);
    293306        ui_scrollbar_set_pos(scrollbar, pos +
    294             ui_scrollbar_through_length(scrollbar) / 4);
     307            ui_scrollbar_trough_length(scrollbar) / 4);
    295308
    296309        pos = ui_scrollbar_get_pos(scrollbar);
     
    432445        rc = ui_prompt_dialog_create(demo->ui, &pdparams, &dialog);
    433446        if (rc != EOK) {
    434                 printf("Error creating message dialog.\n");
     447                printf("Error creating prompt dialog.\n");
    435448                return;
    436449        }
    437450
    438451        ui_prompt_dialog_set_cb(dialog, &prompt_dialog_cb, demo);
     452}
     453
     454/** Edit / Insert Character menu entry selected.
     455 *
     456 * @param mentry Menu entry
     457 * @param arg Argument (demo)
     458 */
     459static void uidemo_edit_insert_character(ui_menu_entry_t *mentry, void *arg)
     460{
     461        ui_demo_t *demo = (ui_demo_t *) arg;
     462        ui_select_dialog_params_t sdparams;
     463        ui_select_dialog_t *dialog;
     464        ui_list_entry_attr_t attr;
     465        errno_t rc;
     466
     467        ui_select_dialog_params_init(&sdparams);
     468        sdparams.caption = "Insert Character";
     469        sdparams.prompt = "Select character to insert";
     470
     471        rc = ui_select_dialog_create(demo->ui, &sdparams, &dialog);
     472        if (rc != EOK) {
     473                printf("Error creating select dialog.\n");
     474                return;
     475        }
     476
     477        ui_list_entry_attr_init(&attr);
     478        attr.caption = "Dollar sign ($)";
     479        attr.arg = (void *)'$';
     480        rc = ui_select_dialog_append(dialog, &attr);
     481        if (rc != EOK) {
     482                printf("Error appending entry to list.\n");
     483                return;
     484        }
     485
     486        ui_list_entry_attr_init(&attr);
     487        attr.caption = "Hash sign (#)";
     488        attr.arg = (void *)'#';
     489        rc = ui_select_dialog_append(dialog, &attr);
     490        if (rc != EOK) {
     491                printf("Error appending entry to list.\n");
     492                return;
     493        }
     494
     495        ui_list_entry_attr_init(&attr);
     496        attr.caption = "Question mark (?)";
     497        attr.arg = (void *)'?';
     498        rc = ui_select_dialog_append(dialog, &attr);
     499        if (rc != EOK) {
     500                printf("Error appending entry to list.\n");
     501                return;
     502        }
     503
     504        ui_select_dialog_set_cb(dialog, &select_dialog_cb, demo);
     505
     506        (void) ui_select_dialog_paint(dialog);
    439507}
    440508
     
    525593/** Prompt dialog cancel button press.
    526594 *
    527  * @param dialog File dialog
     595 * @param dialog Prompt dialog
    528596 * @param arg Argument (ui_demo_t *)
    529597 */
     
    538606/** Prompt dialog close request.
    539607 *
    540  * @param dialog File dialog
     608 * @param dialog Prompt dialog
    541609 * @param arg Argument (ui_demo_t *)
    542610 */
     
    547615        (void) demo;
    548616        ui_prompt_dialog_destroy(dialog);
     617}
     618
     619/** Select dialog OK button press.
     620 *
     621 * @param dialog Select dialog
     622 * @param arg Argument (ui_demo_t *)
     623 * @param text Submitted text
     624 */
     625static void select_dialog_bok(ui_select_dialog_t *dialog, void *arg,
     626    void *earg)
     627{
     628        ui_demo_t *demo = (ui_demo_t *) arg;
     629        char str[2];
     630
     631        ui_select_dialog_destroy(dialog);
     632        str[0] = (char)(intptr_t)earg;
     633        str[1] = '\0';
     634        (void) ui_entry_insert_str(demo->entry, str);
     635}
     636
     637/** Select dialog cancel button press.
     638 *
     639 * @param dialog Select dialog
     640 * @param arg Argument (ui_demo_t *)
     641 */
     642static void select_dialog_bcancel(ui_select_dialog_t *dialog, void *arg)
     643{
     644        ui_demo_t *demo = (ui_demo_t *) arg;
     645
     646        (void) demo;
     647        ui_select_dialog_destroy(dialog);
     648}
     649
     650/** Select dialog close request.
     651 *
     652 * @param dialog Select dialog
     653 * @param arg Argument (ui_demo_t *)
     654 */
     655static void select_dialog_close(ui_select_dialog_t *dialog, void *arg)
     656{
     657        ui_demo_t *demo = (ui_demo_t *) arg;
     658
     659        (void) demo;
     660        ui_select_dialog_destroy(dialog);
    549661}
    550662
     
    598710        ui_menu_entry_t *mexit;
    599711        ui_menu_entry_t *mmodify;
     712        ui_menu_entry_t *minsert_char;
    600713        ui_menu_entry_t *mabout;
    601714        ui_list_entry_attr_t eattr;
     
    652765        }
    653766
    654         rc = ui_menu_create(demo.mbar, "~F~ile", &demo.mfile);
     767        rc = ui_menu_dd_create(demo.mbar, "~F~ile", NULL, &demo.mfile);
    655768        if (rc != EOK) {
    656769                printf("Error creating menu.\n");
     
    692805        }
    693806
     807        ui_menu_entry_set_disabled(mfoobar, true);
     808
    694809        rc = ui_menu_entry_sep_create(demo.mfile, &msep);
    695810        if (rc != EOK) {
     
    706821        ui_menu_entry_set_cb(mexit, uidemo_file_exit, (void *) &demo);
    707822
    708         rc = ui_menu_create(demo.mbar, "~E~dit", &demo.medit);
     823        rc = ui_menu_dd_create(demo.mbar, "~E~dit", NULL, &demo.medit);
    709824        if (rc != EOK) {
    710825                printf("Error creating menu.\n");
     
    720835        ui_menu_entry_set_cb(mmodify, uidemo_edit_modify, (void *) &demo);
    721836
    722         rc = ui_menu_create(demo.mbar, "~P~references", &demo.mpreferences);
     837        rc = ui_menu_entry_create(demo.medit, "~I~nsert Character",
     838            "", &minsert_char);
    723839        if (rc != EOK) {
    724840                printf("Error creating menu.\n");
     
    726842        }
    727843
    728         rc = ui_menu_create(demo.mbar, "~H~elp", &demo.mhelp);
     844        ui_menu_entry_set_cb(minsert_char, uidemo_edit_insert_character,
     845            (void *) &demo);
     846
     847        rc = ui_menu_dd_create(demo.mbar, "~P~references", NULL,
     848            &demo.mpreferences);
     849        if (rc != EOK) {
     850                printf("Error creating menu.\n");
     851                return rc;
     852        }
     853
     854        rc = ui_menu_dd_create(demo.mbar, "~H~elp", NULL, &demo.mhelp);
    729855        if (rc != EOK) {
    730856                printf("Error creating menu.\n");
     
    11441270
    11451271        ui_scrollbar_set_thumb_length(demo.hscrollbar,
    1146             ui_scrollbar_through_length(demo.hscrollbar) / 4);
     1272            ui_scrollbar_trough_length(demo.hscrollbar) / 4);
    11471273
    11481274        rc = ui_fixed_add(demo.bfixed, ui_scrollbar_ctl(demo.hscrollbar));
     
    11761302
    11771303        ui_scrollbar_set_thumb_length(demo.vscrollbar,
    1178             ui_scrollbar_through_length(demo.vscrollbar) / 4);
     1304            ui_scrollbar_trough_length(demo.vscrollbar) / 4);
    11791305
    11801306        rc = ui_fixed_add(demo.bfixed, ui_scrollbar_ctl(demo.vscrollbar));
  • uspace/app/wifi_supplicant/wifi_supplicant.c

    r42c2e65 rdc5c303  
    7575}
    7676
    77 static char *nic_addr_format(nic_address_t *addr)
    78 {
    79         char *str;
    80         int rc = asprintf(&str, "%02x:%02x:%02x:%02x:%02x:%02x",
     77static void nic_addr_format(nic_address_t *addr, char *out, size_t out_size)
     78{
     79        snprintf(out, out_size, "%02x:%02x:%02x:%02x:%02x:%02x",
    8180            addr->address[0], addr->address[1], addr->address[2],
    8281            addr->address[3], addr->address[4], addr->address[5]);
    83 
    84         if (rc < 0)
    85                 return NULL;
    86 
    87         return str;
    8882}
    8983
     
    263257        for (uint8_t i = 0; i < scan_results.length; i++) {
    264258                ieee80211_scan_result_t result = scan_results.results[i];
     259                char mac_addr_hex[18];
     260                nic_addr_format(&result.bssid, mac_addr_hex, 18);
    265261
    266262                printf("%16.16s %17s %4d %5s %5s %7s %7s\n",
    267                     result.ssid, nic_addr_format(&result.bssid),
     263                    result.ssid, mac_addr_hex,
    268264                    result.channel,
    269265                    enum_name(ieee80211_security_type_strs, result.security.type),
Note: See TracChangeset for help on using the changeset viewer.