Changeset 6baab83 in mainline for uspace/lib/ui/src/popup.c


Ignore:
Timestamp:
2021-05-27T17:00:30Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Children:
b4b4dafe
Parents:
f2416ec3
Message:

Set menu popup position based on parent window position

Added a method for getting the position of a display window.
This is then combined with the menu bar entry rectangle (which is
relative to the parent window) to compute a screen-relative
rectangle close to which the popup should be placed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/src/popup.c

    rf2416ec3 r6baab83  
    7878        ui_window_t *window = NULL;
    7979        ui_wnd_params_t wparams;
     80        gfx_coord2_t parent_pos;
    8081        errno_t rc;
    8182
     
    8384        if (popup == NULL)
    8485                return ENOMEM;
     86
     87        rc = ui_window_get_pos(parent, &parent_pos);
     88        if (rc != EOK)
     89                goto error;
    8590
    8691        ui_wnd_params_init(&wparams);
     
    8893        wparams.caption = "";
    8994        wparams.style &= ~ui_wds_decorated;
     95        wparams.placement = ui_wnd_place_popup;
     96
     97        /* Compute position of parent rectangle relative to the screen */
     98        gfx_rect_translate(&parent_pos, &params->place, &wparams.prect);
    9099
    91100        rc = ui_window_create(ui, &wparams, &window);
Note: See TracChangeset for help on using the changeset viewer.