Changeset b0ae23f in mainline


Ignore:
Timestamp:
2023-01-17T15:21:13Z (16 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a0d4afe
Parents:
46a47c0
git-author:
Jiri Svoboda <jiri@…> (2023-01-17 18:21:02)
git-committer:
Jiri Svoboda <jiri@…> (2023-01-17 15:21:13)
Message:

Change the correct pointer's shape when resizing window

The request to resize a window originates from the client. The display
server forces the cursor to a double-arrow shape regardless of whether
it is over the window or not, until the resize is done. This is to
make sure the cursor keeps that shape even if it moves outside of
the current boundaries of the window. With multiple pointers we need
to know which one to change. This is done by passing the pos_id from
button press event that starts the resize all the way to
ds_window_start_resize(). Then it needs to be stored in the window
structure for use when it is time to restore the cursor.

Location:
uspace
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/display/include/disp_srv.h

    r46a47c0 rb0ae23f  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    5959        errno_t (*window_move_req)(void *, sysarg_t, gfx_coord2_t *);
    6060        errno_t (*window_resize_req)(void *, sysarg_t, display_wnd_rsztype_t,
    61             gfx_coord2_t *);
     61            gfx_coord2_t *, sysarg_t);
    6262        errno_t (*window_move)(void *, sysarg_t, gfx_coord2_t *);
    6363        errno_t (*window_get_pos)(void *, sysarg_t, gfx_coord2_t *);
  • uspace/lib/display/include/display.h

    r46a47c0 rb0ae23f  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    5656extern errno_t display_window_move_req(display_window_t *, gfx_coord2_t *);
    5757extern errno_t display_window_resize_req(display_window_t *,
    58     display_wnd_rsztype_t, gfx_coord2_t *);
     58    display_wnd_rsztype_t, gfx_coord2_t *, sysarg_t);
    5959extern errno_t display_window_move(display_window_t *, gfx_coord2_t *);
    6060extern errno_t display_window_get_pos(display_window_t *, gfx_coord2_t *);
  • uspace/lib/display/src/disp_srv.c

    r46a47c0 rb0ae23f  
    320320        display_wnd_rsztype_t rsztype;
    321321        gfx_coord2_t pos;
     322        sysarg_t pos_id;
    322323        size_t size;
    323324        errno_t rc;
     
    325326        wnd_id = ipc_get_arg1(icall);
    326327        rsztype = (display_wnd_rsztype_t) ipc_get_arg2(icall);
     328        pos_id = ipc_get_arg3(icall);
    327329
    328330        if (!async_data_write_receive(&call, &size)) {
     
    350352        }
    351353
    352         rc = srv->ops->window_resize_req(srv->arg, wnd_id, rsztype, &pos);
     354        rc = srv->ops->window_resize_req(srv->arg, wnd_id, rsztype, &pos,
     355            pos_id);
    353356        async_answer_0(icall, rc);
    354357}
  • uspace/lib/display/src/display.c

    r46a47c0 rb0ae23f  
    414414 * @param rsztype Resize type (which part of window frame is being dragged)
    415415 * @param pos Position in the window where the button was pressed
     416 * @param pos_id Positioning device ID
    416417 * @return EOK on success or an error code
    417418 */
    418419errno_t display_window_resize_req(display_window_t *window,
    419     display_wnd_rsztype_t rsztype, gfx_coord2_t *pos)
    420 {
    421         async_exch_t *exch;
    422         aid_t req;
    423         ipc_call_t answer;
    424         errno_t rc;
    425 
    426         exch = async_exchange_begin(window->display->sess);
    427         req = async_send_2(exch, DISPLAY_WINDOW_RESIZE_REQ, window->id,
    428             (sysarg_t) rsztype, &answer);
     420    display_wnd_rsztype_t rsztype, gfx_coord2_t *pos, sysarg_t pos_id)
     421{
     422        async_exch_t *exch;
     423        aid_t req;
     424        ipc_call_t answer;
     425        errno_t rc;
     426
     427        exch = async_exchange_begin(window->display->sess);
     428        req = async_send_3(exch, DISPLAY_WINDOW_RESIZE_REQ, window->id,
     429            (sysarg_t) rsztype, pos_id, &answer);
    429430        rc = async_data_write_start(exch, (void *)pos, sizeof (gfx_coord2_t));
    430431        async_exchange_end(exch);
  • uspace/lib/display/test/display.c

    r46a47c0 rb0ae23f  
    6363static errno_t test_window_get_max_rect(void *, sysarg_t, gfx_rect_t *);
    6464static errno_t test_window_resize_req(void *, sysarg_t, display_wnd_rsztype_t,
    65     gfx_coord2_t *);
     65    gfx_coord2_t *, sysarg_t);
    6666static errno_t test_window_resize(void *, sysarg_t, gfx_coord2_t *,
    6767    gfx_rect_t *);
     
    141141        display_wnd_rsztype_t resize_req_rsztype;
    142142        gfx_coord2_t resize_req_pos;
     143        sysarg_t resize_req_pos_id;
    143144
    144145        bool window_resize_called;
     
    831832        display_wnd_rsztype_t rsztype;
    832833        gfx_coord2_t pos;
     834        sysarg_t pos_id;
    833835
    834836        async_set_fallback_port_handler(test_display_conn, &resp);
     
    863865        pos.x = 42;
    864866        pos.y = 43;
    865 
    866         rc = display_window_resize_req(wnd, rsztype, &pos);
     867        pos_id = 44;
     868
     869        rc = display_window_resize_req(wnd, rsztype, &pos, pos_id);
    867870        PCUT_ASSERT_TRUE(resp.window_resize_req_called);
    868871        PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
     
    871874        PCUT_ASSERT_INT_EQUALS(pos.x, resp.resize_req_pos.x);
    872875        PCUT_ASSERT_INT_EQUALS(pos.y, resp.resize_req_pos.y);
     876        PCUT_ASSERT_INT_EQUALS(pos_id, resp.resize_req_pos_id);
    873877
    874878        display_window_destroy(wnd);
     
    889893        display_wnd_rsztype_t rsztype;
    890894        gfx_coord2_t pos;
     895        sysarg_t pos_id;
    891896
    892897        async_set_fallback_port_handler(test_display_conn, &resp);
     
    921926        pos.x = 42;
    922927        pos.y = 43;
    923 
    924         rc = display_window_resize_req(wnd, rsztype, &pos);
     928        pos_id = 44;
     929
     930        rc = display_window_resize_req(wnd, rsztype, &pos, pos_id);
    925931        PCUT_ASSERT_TRUE(resp.window_resize_req_called);
    926932        PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
     
    929935        PCUT_ASSERT_INT_EQUALS(pos.x, resp.resize_req_pos.x);
    930936        PCUT_ASSERT_INT_EQUALS(pos.y, resp.resize_req_pos.y);
     937        PCUT_ASSERT_INT_EQUALS(pos_id, resp.resize_req_pos_id);
    931938
    932939        display_window_destroy(wnd);
     
    21882195
    21892196static errno_t test_window_resize_req(void *arg, sysarg_t wnd_id,
    2190     display_wnd_rsztype_t rsztype, gfx_coord2_t *pos)
     2197    display_wnd_rsztype_t rsztype, gfx_coord2_t *pos, sysarg_t pos_id)
    21912198{
    21922199        test_response_t *resp = (test_response_t *) arg;
     
    21962203        resp->resize_req_wnd_id = wnd_id;
    21972204        resp->resize_req_pos = *pos;
     2205        resp->resize_req_pos_id = pos_id;
    21982206        return resp->rc;
    21992207}
  • uspace/lib/ui/include/types/ui/wdecor.h

    r46a47c0 rb0ae23f  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    8787        void (*move)(ui_wdecor_t *, void *, gfx_coord2_t *);
    8888        void (*resize)(ui_wdecor_t *, void *, ui_wdecor_rsztype_t,
    89             gfx_coord2_t *);
     89            gfx_coord2_t *, sysarg_t);
    9090        void (*set_cursor)(ui_wdecor_t *, void *, ui_stock_cursor_t);
    9191} ui_wdecor_cb_t;
  • uspace/lib/ui/private/wdecor.h

    r46a47c0 rb0ae23f  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    100100extern void ui_wdecor_move(ui_wdecor_t *, gfx_coord2_t *);
    101101extern void ui_wdecor_resize(ui_wdecor_t *, ui_wdecor_rsztype_t,
    102     gfx_coord2_t *);
     102    gfx_coord2_t *, sysarg_t);
    103103extern void ui_wdecor_set_cursor(ui_wdecor_t *, ui_stock_cursor_t);
    104104extern void ui_wdecor_get_geom(ui_wdecor_t *, ui_wdecor_geom_t *);
  • uspace/lib/ui/src/wdecor.c

    r46a47c0 rb0ae23f  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    477477 * @param rsztype Resize type
    478478 * @param pos Position where the button was pressed
     479 * @param pos_id Positioning device ID
    479480 */
    480481void ui_wdecor_resize(ui_wdecor_t *wdecor, ui_wdecor_rsztype_t rsztype,
    481     gfx_coord2_t *pos)
     482    gfx_coord2_t *pos, sysarg_t pos_id)
    482483{
    483484        if (wdecor->cb != NULL && wdecor->cb->resize != NULL)
    484                 wdecor->cb->resize(wdecor, wdecor->arg, rsztype, pos);
     485                wdecor->cb->resize(wdecor, wdecor->arg, rsztype, pos, pos_id);
    485486}
    486487
     
    826827        /* Press on window border? */
    827828        if (rsztype != ui_wr_none && event->type == POS_PRESS)
    828                 ui_wdecor_resize(wdecor, rsztype, &pos);
     829                ui_wdecor_resize(wdecor, rsztype, &pos, event->pos_id);
    829830}
    830831
  • uspace/lib/ui/src/window.c

    r46a47c0 rb0ae23f  
    8080static void wd_move(ui_wdecor_t *, void *, gfx_coord2_t *);
    8181static void wd_resize(ui_wdecor_t *, void *, ui_wdecor_rsztype_t,
    82     gfx_coord2_t *);
     82    gfx_coord2_t *, sysarg_t);
    8383static void wd_set_cursor(ui_wdecor_t *, void *, ui_stock_cursor_t);
    8484
     
    988988 * @param rsztype Resize type
    989989 * @param pos Position where the button was pressed
     990 * @param pos_id Positioning device ID
    990991 */
    991992static void wd_resize(ui_wdecor_t *wdecor, void *arg,
    992     ui_wdecor_rsztype_t rsztype, gfx_coord2_t *pos)
    993 {
    994         ui_window_t *window = (ui_window_t *) arg;
    995 
    996         if (window->dwindow != NULL)
    997                 (void) display_window_resize_req(window->dwindow, rsztype, pos);
     993    ui_wdecor_rsztype_t rsztype, gfx_coord2_t *pos, sysarg_t pos_id)
     994{
     995        ui_window_t *window = (ui_window_t *) arg;
     996
     997        if (window->dwindow != NULL) {
     998                (void) display_window_resize_req(window->dwindow, rsztype,
     999                    pos, pos_id);
     1000        }
    9981001}
    9991002
  • uspace/lib/ui/test/wdecor.c

    r46a47c0 rb0ae23f  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    6868static void test_wdecor_move(ui_wdecor_t *, void *, gfx_coord2_t *);
    6969static void test_wdecor_resize(ui_wdecor_t *, void *, ui_wdecor_rsztype_t,
    70     gfx_coord2_t *);
     70    gfx_coord2_t *, sysarg_t);
    7171static void test_wdecor_set_cursor(ui_wdecor_t *, void *, ui_stock_cursor_t);
    7272
     
    108108        bool move;
    109109        gfx_coord2_t pos;
     110        sysarg_t pos_id;
    110111        bool resize;
    111112        ui_wdecor_rsztype_t rsztype;
     
    373374        ui_wdecor_rsztype_t rsztype;
    374375        gfx_coord2_t pos;
     376        sysarg_t pos_id;
    375377
    376378        rc = ui_wdecor_create(NULL, "Hello", ui_wds_none, &wdecor);
     
    380382        pos.x = 3;
    381383        pos.y = 4;
     384        pos_id = 5;
    382385
    383386        /* Resize callback with no callbacks set */
    384         ui_wdecor_resize(wdecor, rsztype, &pos);
     387        ui_wdecor_resize(wdecor, rsztype, &pos, pos_id);
    385388
    386389        /* Resize callback with move callback not implemented */
    387390        ui_wdecor_set_cb(wdecor, &dummy_wdecor_cb, NULL);
    388         ui_wdecor_resize(wdecor, rsztype, &pos);
     391        ui_wdecor_resize(wdecor, rsztype, &pos, pos_id);
    389392
    390393        /* Resize callback with real callback set */
     
    394397        resp.pos.y = 0;
    395398        ui_wdecor_set_cb(wdecor, &test_wdecor_cb, &resp);
    396         ui_wdecor_resize(wdecor, rsztype, &pos);
     399        ui_wdecor_resize(wdecor, rsztype, &pos, pos_id);
    397400        PCUT_ASSERT_TRUE(resp.resize);
    398401        PCUT_ASSERT_INT_EQUALS(rsztype, resp.rsztype);
    399402        PCUT_ASSERT_INT_EQUALS(pos.x, resp.pos.x);
    400403        PCUT_ASSERT_INT_EQUALS(pos.y, resp.pos.y);
     404        PCUT_ASSERT_INT_EQUALS(pos_id, resp.pos_id);
    401405
    402406        ui_wdecor_destroy(wdecor);
     
    10801084
    10811085static void test_wdecor_resize(ui_wdecor_t *wdecor, void *arg,
    1082     ui_wdecor_rsztype_t rsztype, gfx_coord2_t *pos)
     1086    ui_wdecor_rsztype_t rsztype, gfx_coord2_t *pos, sysarg_t pos_id)
    10831087{
    10841088        test_cb_resp_t *resp = (test_cb_resp_t *) arg;
     
    10871091        resp->rsztype = rsztype;
    10881092        resp->pos = *pos;
     1093        resp->pos_id = pos_id;
    10891094}
    10901095
  • uspace/srv/hid/display/dsops.c

    r46a47c0 rb0ae23f  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    5151static errno_t disp_window_get_max_rect(void *, sysarg_t, gfx_rect_t *);
    5252static errno_t disp_window_resize_req(void *, sysarg_t,
    53     display_wnd_rsztype_t, gfx_coord2_t *);
     53    display_wnd_rsztype_t, gfx_coord2_t *, sysarg_t);
    5454static errno_t disp_window_resize(void *, sysarg_t, gfx_coord2_t *,
    5555    gfx_rect_t *);
     
    206206
    207207static errno_t disp_window_resize_req(void *arg, sysarg_t wnd_id,
    208     display_wnd_rsztype_t rsztype, gfx_coord2_t *pos)
     208    display_wnd_rsztype_t rsztype, gfx_coord2_t *pos, sysarg_t pos_id)
    209209{
    210210        ds_client_t *client = (ds_client_t *) arg;
     
    223223
    224224        log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_resize_req()");
    225         ds_window_resize_req(wnd, rsztype, pos);
     225        ds_window_resize_req(wnd, rsztype, pos, pos_id);
    226226        ds_display_unlock(client->display);
    227227        return EOK;
  • uspace/srv/hid/display/test/window.c

    r46a47c0 rb0ae23f  
    758758        display_wnd_params_t params;
    759759        gfx_coord2_t pos;
     760        sysarg_t pos_id;
    760761        errno_t rc;
    761762
     
    783784        pos.x = 42;
    784785        pos.y = 43;
    785         ds_window_resize_req(wnd, display_wr_top_right, &pos);
     786        pos_id = 44;
     787        ds_window_resize_req(wnd, display_wr_top_right, &pos, pos_id);
    786788
    787789        PCUT_ASSERT_INT_EQUALS(dsw_resizing, wnd->state);
  • uspace/srv/hid/display/types/display/window.h

    r46a47c0 rb0ae23f  
    103103        /** Original position before started to move or resize the window */
    104104        gfx_coord2_t orig_pos;
     105        /** Positioning device that started the resize */
     106        sysarg_t orig_pos_id;
    105107        /** Window resize type (if state is dsw_resizing) */
    106108        display_wnd_rsztype_t rsztype;
  • uspace/srv/hid/display/window.c

    r46a47c0 rb0ae23f  
    510510 * @param rsztype Resize type (which part of window is being dragged)
    511511 * @param pos Position where mouse button was pressed
     512 * @param pos_id Positioning device ID
    512513 */
    513514static void ds_window_start_resize(ds_window_t *wnd,
    514     display_wnd_rsztype_t rsztype, gfx_coord2_t *pos)
     515    display_wnd_rsztype_t rsztype, gfx_coord2_t *pos, sysarg_t pos_id)
    515516{
    516517        ds_seat_t *seat;
     
    523524                return;
    524525
     526        /* Determine which seat started the resize */
     527        seat = ds_display_seat_by_idev(wnd->display, pos_id);
     528        if (seat == NULL)
     529                return;
     530
    525531        wnd->orig_pos = *pos;
     532        wnd->orig_pos_id = pos_id;
    526533        wnd->state = dsw_resizing;
    527534        wnd->rsztype = rsztype;
    528535        wnd->preview_rect = wnd->rect;
    529536
    530         // TODO Multi-seat: need client to tell us which seat started the resize!
    531         seat = ds_display_first_seat(wnd->display);
    532537        ctype = display_cursor_from_wrsz(rsztype);
    533538        ds_seat_set_wm_cursor(seat, wnd->display->cursor[ctype]);
     
    559564        ds_client_post_resize_event(wnd->client, wnd, &nrect);
    560565
    561         // TODO Multi-seat: Need to know which seat started the resize!
    562         seat = ds_display_first_seat(wnd->display);
    563         ds_seat_set_wm_cursor(seat, NULL);
     566        /* Determine which seat started the resize */
     567        seat = ds_display_seat_by_idev(wnd->display, wnd->orig_pos_id);
     568        if (seat != NULL)
     569                ds_seat_set_wm_cursor(seat, NULL);
    564570
    565571        (void) ds_display_paint(wnd->display, NULL);
     
    787793 * @param pos Position where the pointer was when the resize started
    788794 *            relative to the window
     795 * @param pos_id Positioning device ID
    789796 * @param event Button press event
    790797 */
    791798void ds_window_resize_req(ds_window_t *wnd, display_wnd_rsztype_t rsztype,
    792     gfx_coord2_t *pos)
     799    gfx_coord2_t *pos, sysarg_t pos_id)
    793800{
    794801        gfx_coord2_t orig_pos;
    795802
    796         log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_resize_req (%d, %d, %d)",
    797             (int) rsztype, (int) pos->x, (int) pos->y);
     803        log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_resize_req (%d, %d, %d, %d)",
     804            (int)rsztype, (int)pos->x, (int)pos->y, (int)pos_id);
    798805
    799806        gfx_coord2_add(&wnd->dpos, pos, &orig_pos);
    800         ds_window_start_resize(wnd, rsztype, &orig_pos);
     807        ds_window_start_resize(wnd, rsztype, &orig_pos, pos_id);
    801808}
    802809
  • uspace/srv/hid/display/window.h

    r46a47c0 rb0ae23f  
    6868extern void ds_window_get_max_rect(ds_window_t *, gfx_rect_t *);
    6969extern void ds_window_resize_req(ds_window_t *, display_wnd_rsztype_t,
    70     gfx_coord2_t *);
     70    gfx_coord2_t *, sysarg_t);
    7171extern errno_t ds_window_resize(ds_window_t *, gfx_coord2_t *, gfx_rect_t *);
    7272extern errno_t ds_window_minimize(ds_window_t *);
Note: See TracChangeset for help on using the changeset viewer.