Changeset 1e4a937 in mainline for uspace/lib/display/src


Ignore:
Timestamp:
2020-03-09T11:03:58Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e022819
Parents:
a2e104e
git-author:
Jiri Svoboda <jiri@…> (2020-03-08 10:02:08)
git-committer:
Jiri Svoboda <jiri@…> (2020-03-09 11:03:58)
Message:

Add libdisplay method for initiating window resize

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

Legend:

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

    ra2e104e r1e4a937  
    3737#include <disp_srv.h>
    3838#include <display/event.h>
     39#include <display/wndresize.h>
    3940#include <errno.h>
    4041#include <io/log.h>
     
    147148}
    148149
     150static void display_window_resize_req_srv(display_srv_t *srv, ipc_call_t *icall)
     151{
     152        sysarg_t wnd_id;
     153        ipc_call_t call;
     154        display_wnd_rsztype_t rsztype;
     155        gfx_coord2_t pos;
     156        size_t size;
     157        errno_t rc;
     158
     159        wnd_id = ipc_get_arg1(icall);
     160        rsztype = (display_wnd_rsztype_t) ipc_get_arg2(icall);
     161
     162        if (!async_data_write_receive(&call, &size)) {
     163                async_answer_0(&call, EREFUSED);
     164                async_answer_0(icall, EREFUSED);
     165                return;
     166        }
     167
     168        if (size != sizeof(gfx_coord2_t)) {
     169                async_answer_0(&call, EINVAL);
     170                async_answer_0(icall, EINVAL);
     171                return;
     172        }
     173
     174        rc = async_data_write_finalize(&call, &pos, size);
     175        if (rc != EOK) {
     176                async_answer_0(&call, rc);
     177                async_answer_0(icall, rc);
     178                return;
     179        }
     180
     181        if (srv->ops->window_resize_req == NULL) {
     182                async_answer_0(icall, ENOTSUP);
     183                return;
     184        }
     185
     186        rc = srv->ops->window_resize_req(srv->arg, wnd_id, rsztype, &pos);
     187        async_answer_0(icall, rc);
     188}
     189
    149190static void display_window_resize_srv(display_srv_t *srv, ipc_call_t *icall)
    150191{
     
    256297                case DISPLAY_WINDOW_MOVE_REQ:
    257298                        display_window_move_req_srv(srv, &call);
     299                        break;
     300                case DISPLAY_WINDOW_RESIZE_REQ:
     301                        display_window_resize_req_srv(srv, &call);
    258302                        break;
    259303                case DISPLAY_WINDOW_RESIZE:
  • uspace/lib/display/src/display.c

    ra2e104e r1e4a937  
    251251 *
    252252 * @param window Window
     253 * @param pos Position in the window where the button was pressed
    253254 * @return EOK on success or an error code
    254255 */
     
    262263        exch = async_exchange_begin(window->display->sess);
    263264        req = async_send_1(exch, DISPLAY_WINDOW_MOVE_REQ, window->id, &answer);
     265        rc = async_data_write_start(exch, (void *)pos, sizeof (gfx_coord2_t));
     266        async_exchange_end(exch);
     267        if (rc != EOK) {
     268                async_forget(req);
     269                return rc;
     270        }
     271
     272        async_wait_for(req, &rc);
     273        if (rc != EOK)
     274                return rc;
     275
     276        return EOK;
     277}
     278
     279/** Request a window resize.
     280 *
     281 * Request the display service to initiate a user window resize operation
     282 * (i.e. let the user resize the window). Used when the client detects
     283 * mouse press on the window frame or such.
     284 *
     285 * @param window Window
     286 * @param rsztype Resize type (which part of window frame is being dragged)
     287 * @param pos Position in the window where the button was pressed
     288 * @return EOK on success or an error code
     289 */
     290errno_t display_window_resize_req(display_window_t *window,
     291    display_wnd_rsztype_t rsztype, gfx_coord2_t *pos)
     292{
     293        async_exch_t *exch;
     294        aid_t req;
     295        ipc_call_t answer;
     296        errno_t rc;
     297
     298        exch = async_exchange_begin(window->display->sess);
     299        req = async_send_2(exch, DISPLAY_WINDOW_RESIZE_REQ, window->id,
     300            (sysarg_t) rsztype, &answer);
    264301        rc = async_data_write_start(exch, (void *)pos, sizeof (gfx_coord2_t));
    265302        async_exchange_end(exch);
Note: See TracChangeset for help on using the changeset viewer.