Changeset 6baab83 in mainline for uspace/lib/display/src/disp_srv.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/display/src/disp_srv.c

    rf2416ec3 r6baab83  
    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:
Note: See TracChangeset for help on using the changeset viewer.