Changeset c9927c66 in mainline for uspace/lib/display/src


Ignore:
Timestamp:
2021-06-10T13:22:33Z (4 years ago)
Author:
jxsvoboda <5887334+jxsvoboda@…>
Branches:
master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9e84d2c
Parents:
c68c18b9
git-author:
Jiri Svoboda <jiri@…> (2021-05-27 17:00:30)
git-committer:
jxsvoboda <5887334+jxsvoboda@…> (2021-06-10 13:22:33)
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.

Location:
uspace/lib/display/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/display/src/disp_srv.c

    rc68c18b9 rc9927c66  
    11/*
    2  * Copyright (c) 2019 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    187187}
    188188
     189static void display_window_get_pos_srv(display_srv_t *srv, ipc_call_t *icall)
     190{
     191        sysarg_t wnd_id;
     192        ipc_call_t call;
     193        gfx_coord2_t dpos;
     194        size_t size;
     195        errno_t rc;
     196
     197        wnd_id = ipc_get_arg1(icall);
     198
     199        if (srv->ops->window_get_pos == NULL) {
     200                async_answer_0(icall, ENOTSUP);
     201                return;
     202        }
     203
     204        if (!async_data_read_receive(&call, &size)) {
     205                async_answer_0(icall, EREFUSED);
     206                return;
     207        }
     208
     209        rc = srv->ops->window_get_pos(srv->arg, wnd_id, &dpos);
     210        if (rc != EOK) {
     211                async_answer_0(&call, rc);
     212                async_answer_0(icall, rc);
     213                return;
     214        }
     215
     216        if (size != sizeof(gfx_coord2_t)) {
     217                async_answer_0(&call, EINVAL);
     218                async_answer_0(icall, EINVAL);
     219                return;
     220        }
     221
     222        rc = async_data_read_finalize(&call, &dpos, size);
     223        if (rc != EOK) {
     224                async_answer_0(&call, rc);
     225                async_answer_0(icall, rc);
     226                return;
     227        }
     228
     229        async_answer_0(icall, EOK);
     230}
     231
    189232static void display_window_resize_req_srv(display_srv_t *srv, ipc_call_t *icall)
    190233{
     
    398441                case DISPLAY_WINDOW_MOVE:
    399442                        display_window_move_srv(srv, &call);
     443                        break;
     444                case DISPLAY_WINDOW_GET_POS:
     445                        display_window_get_pos_srv(srv, &call);
    400446                        break;
    401447                case DISPLAY_WINDOW_RESIZE_REQ:
  • uspace/lib/display/src/display.c

    rc68c18b9 rc9927c66  
    11/*
    2  * Copyright (c) 2019 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    319319}
    320320
     321/** Get display window position.
     322 *
     323 * Get display window position on the display.
     324 *
     325 * @param window Window
     326 * @param dpos Place to store position
     327 * @return EOK on success or an error code
     328 */
     329errno_t display_window_get_pos(display_window_t *window, gfx_coord2_t *dpos)
     330{
     331        async_exch_t *exch;
     332        aid_t req;
     333        ipc_call_t answer;
     334        errno_t rc;
     335
     336        exch = async_exchange_begin(window->display->sess);
     337        req = async_send_1(exch, DISPLAY_WINDOW_GET_POS, window->id, &answer);
     338        rc = async_data_read_start(exch, dpos, sizeof (gfx_coord2_t));
     339        async_exchange_end(exch);
     340        if (rc != EOK) {
     341                async_forget(req);
     342                return rc;
     343        }
     344
     345        async_wait_for(req, &rc);
     346        if (rc != EOK)
     347                return rc;
     348
     349        return EOK;
     350}
     351
    321352/** Request a window resize.
    322353 *
Note: See TracChangeset for help on using the changeset viewer.