Changeset 06d0c81 in mainline


Ignore:
Timestamp:
2020-11-19T22:38:17Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
20667af
Parents:
2e0a2e7
Message:

Window placement

Needed to recreate the current 'desktop' and keep CI tests working

Location:
uspace
Files:
8 edited

Legend:

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

    r2e0a2e7 r06d0c81  
    362362        ui_wnd_params_init(&params);
    363363        params.caption = "";
     364        params.placement = ui_wnd_place_bottom_right;
    364365        /*
    365366         * Compute window rectangle such that application area corresponds
  • uspace/app/init/init.c

    r2e0a2e7 r06d0c81  
    277277}
    278278
    279 static int app_start(const char *app)
     279static int app_start(const char *app, const char *arg)
    280280{
    281281        printf("%s: Spawning %s\n", NAME, app);
     
    283283        task_id_t id;
    284284        task_wait_t wait;
    285         errno_t rc = task_spawnl(&id, &wait, app, app, NULL);
     285        errno_t rc = task_spawnl(&id, &wait, app, app, arg, NULL);
    286286        if (rc != EOK) {
    287287                oom_check(rc, app);
     
    471471                rc = display_server();
    472472                if (rc == EOK) {
    473                         app_start("/app/terminal");
    474                         app_start("/app/launcher");
    475                         app_start("/app/barber");
     473                        app_start("/app/launcher", NULL);
     474                        app_start("/app/barber", NULL);
     475                        app_start("/app/terminal", "-topleft");
    476476                }
    477477        }
  • uspace/app/launcher/launcher.c

    r2e0a2e7 r06d0c81  
    184184        ui_wnd_params_init(&params);
    185185        params.caption = "Launcher";
     186        params.placement = ui_wnd_place_top_right;
    186187        params.rect.p0.x = 0;
    187188        params.rect.p0.y = 0;
  • uspace/app/terminal/main.c

    r2e0a2e7 r06d0c81  
    4343static void print_syntax(void)
    4444{
    45         printf("Syntax: %s [-d <display-spec>]\n", NAME);
     45        printf("Syntax: %s [<options>]\n", NAME);
     46        printf("\t-d <display-spec> Use the specified display\n");
     47        printf("\t-topleft]         Place window to the top-left corner of "
     48            "the screen\n");
    4649}
    4750
     
    5053        const char *display_spec = UI_DISPLAY_DEFAULT;
    5154        terminal_t *terminal = NULL;
     55        terminal_flags_t flags = 0;
    5256        errno_t rc;
    5357        int i;
     
    6468
    6569                        display_spec = argv[i++];
     70                } else if (str_cmp(argv[i], "-topleft") == 0) {
     71                        ++i;
     72                        flags |= tf_topleft;
    6673                } else {
    6774                        printf("Invalid option '%s'.\n", argv[i]);
     
    7683        }
    7784
    78         rc = terminal_create(display_spec, 640, 480, &terminal);
     85        rc = terminal_create(display_spec, 640, 480, flags, &terminal);
    7986        if (rc != EOK)
    8087                return 1;
  • uspace/app/terminal/terminal.c

    r2e0a2e7 r06d0c81  
    756756
    757757errno_t terminal_create(const char *display_spec, sysarg_t width,
    758     sysarg_t height, terminal_t **rterm)
     758    sysarg_t height, terminal_flags_t flags, terminal_t **rterm)
    759759{
    760760        terminal_t *term;
     
    811811        ui_wnd_params_init(&wparams);
    812812        wparams.caption = "Terminal";
     813        if ((flags & tf_topleft) != 0)
     814                wparams.placement = ui_wnd_place_top_left;
    813815
    814816        /*
  • uspace/app/terminal/terminal.h

    r2e0a2e7 r06d0c81  
    5454#define UTF8_CHAR_BUFFER_SIZE  (STR_BOUNDS(1) + 1)
    5555
     56typedef enum {
     57        tf_topleft = 1
     58} terminal_flags_t;
     59
    5660typedef struct {
    5761        ui_t *ui;
     
    8589} terminal_t;
    8690
    87 extern errno_t terminal_create(const char *, sysarg_t, sysarg_t, terminal_t **);
     91extern errno_t terminal_create(const char *, sysarg_t, sysarg_t,
     92    terminal_flags_t, terminal_t **);
    8893extern void terminal_destroy(terminal_t *);
    8994
  • uspace/lib/ui/include/types/ui/window.h

    r2e0a2e7 r06d0c81  
    4444typedef struct ui_window ui_window_t;
    4545
     46/** Window placement hint */
     47typedef enum {
     48        /** Use default (automatic) placement */
     49        ui_wnd_place_default = 0,
     50        /** Place window to the top-left corner of the screen */
     51        ui_wnd_place_top_left,
     52        /** Place window to the top-right corner of the screen */
     53        ui_wnd_place_top_right,
     54        /** Place window to the bottom-left corner of the screen */
     55        ui_wnd_place_bottom_left,
     56        /** Place window to the bottom-right corner of the screen */
     57        ui_wnd_place_bottom_right
     58} ui_wnd_placement_t;
     59
    4660/** Window parameters */
    4761typedef struct {
     
    5064        /** Window caption */
    5165        const char *caption;
     66        /** Window placement */
     67        ui_wnd_placement_t placement;
    5268} ui_wnd_params_t;
    5369
  • uspace/lib/ui/src/window.c

    r2e0a2e7 r06d0c81  
    102102{
    103103        ui_window_t *window;
     104        display_info_t info;
     105        gfx_coord2_t pos;
    104106        display_wnd_params_t dparams;
    105107        display_window_t *dwindow = NULL;
     
    122124                if (rc != EOK)
    123125                        goto error;
     126
     127                if (params->placement != ui_wnd_place_default) {
     128                        rc = display_get_info(ui->display, &info);
     129                        if (rc != EOK)
     130                                goto error;
     131
     132                        pos.x = 0;
     133                        pos.y = 0;
     134
     135                        switch (params->placement) {
     136                        case ui_wnd_place_default:
     137                                assert(false);
     138                        case ui_wnd_place_top_left:
     139                                pos.x = info.rect.p0.x - params->rect.p0.x;
     140                                pos.y = info.rect.p0.y - params->rect.p0.y;
     141                                break;
     142                        case ui_wnd_place_top_right:
     143                                pos.x = info.rect.p1.x - params->rect.p1.x;
     144                                pos.y = info.rect.p0.y - params->rect.p0.y;
     145                                break;
     146                        case ui_wnd_place_bottom_left:
     147                                pos.x = info.rect.p0.x - params->rect.p0.x;
     148                                pos.y = info.rect.p1.y - params->rect.p1.y;
     149                                break;
     150                        case ui_wnd_place_bottom_right:
     151                                pos.x = info.rect.p1.x - params->rect.p1.x;
     152                                pos.y = info.rect.p1.y - params->rect.p1.y;
     153                                break;
     154                        }
     155
     156                        rc = display_window_move(dwindow, &pos);
     157                        if (rc != EOK)
     158                                goto error;
     159                }
    124160
    125161                rc = display_window_get_gc(dwindow, &gc);
Note: See TracChangeset for help on using the changeset viewer.