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


Ignore:
Timestamp:
2020-03-05T11:23:41Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1e4a937
Parents:
338d0935
git-author:
Jiri Svoboda <jiri@…> (2020-03-04 19:23:29)
git-committer:
Jiri Svoboda <jiri@…> (2020-03-05 11:23:41)
Message:

Move windows by dragging decoration

Or dragging anywhere with button 2. Need to add Ctrl/Alt/Shift state
to pos_event_t and change the latter to Alt-drag/Shift-drag.

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

Legend:

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

    r338d0935 ra2e104e  
    100100        wnd_id = ipc_get_arg1(icall);
    101101
    102         if (srv->ops->window_create == NULL) {
     102        if (srv->ops->window_destroy == NULL) {
    103103                async_answer_0(icall, ENOTSUP);
    104104                return;
     
    106106
    107107        rc = srv->ops->window_destroy(srv->arg, wnd_id);
     108        async_answer_0(icall, rc);
     109}
     110
     111static void display_window_move_req_srv(display_srv_t *srv, ipc_call_t *icall)
     112{
     113        sysarg_t wnd_id;
     114        ipc_call_t call;
     115        gfx_coord2_t pos;
     116        size_t size;
     117        errno_t rc;
     118
     119        wnd_id = ipc_get_arg1(icall);
     120
     121        if (!async_data_write_receive(&call, &size)) {
     122                async_answer_0(&call, EREFUSED);
     123                async_answer_0(icall, EREFUSED);
     124                return;
     125        }
     126
     127        if (size != sizeof(gfx_coord2_t)) {
     128                async_answer_0(&call, EINVAL);
     129                async_answer_0(icall, EINVAL);
     130                return;
     131        }
     132
     133        rc = async_data_write_finalize(&call, &pos, size);
     134        if (rc != EOK) {
     135                async_answer_0(&call, rc);
     136                async_answer_0(icall, rc);
     137                return;
     138        }
     139
     140        if (srv->ops->window_move_req == NULL) {
     141                async_answer_0(icall, ENOTSUP);
     142                return;
     143        }
     144
     145        rc = srv->ops->window_move_req(srv->arg, wnd_id, &pos);
    108146        async_answer_0(icall, rc);
    109147}
     
    215253                case DISPLAY_WINDOW_DESTROY:
    216254                        display_window_destroy_srv(srv, &call);
     255                        break;
     256                case DISPLAY_WINDOW_MOVE_REQ:
     257                        display_window_move_req_srv(srv, &call);
    217258                        break;
    218259                case DISPLAY_WINDOW_RESIZE:
  • uspace/lib/display/src/display.c

    r338d0935 ra2e104e  
    244244}
    245245
     246/** Request a window move.
     247 *
     248 * Request the display service to initiate a user window move operation
     249 * (i.e. let the user move the window). Used when the client detects
     250 * mouse press on the title bar or such.
     251 *
     252 * @param window Window
     253 * @return EOK on success or an error code
     254 */
     255errno_t display_window_move_req(display_window_t *window, gfx_coord2_t *pos)
     256{
     257        async_exch_t *exch;
     258        aid_t req;
     259        ipc_call_t answer;
     260        errno_t rc;
     261
     262        exch = async_exchange_begin(window->display->sess);
     263        req = async_send_1(exch, DISPLAY_WINDOW_MOVE_REQ, window->id, &answer);
     264        rc = async_data_write_start(exch, (void *)pos, sizeof (gfx_coord2_t));
     265        async_exchange_end(exch);
     266        if (rc != EOK) {
     267                async_forget(req);
     268                return rc;
     269        }
     270
     271        async_wait_for(req, &rc);
     272        if (rc != EOK)
     273                return rc;
     274
     275        return EOK;
     276}
     277
    246278/** Resize display window.
    247279 *
     
    283315 * @param nrect New bounding rectangle
    284316 * @param offs
    285  * @return EOK on success or an error code. In both cases @a window must
    286  *         not be accessed anymore
     317 * @return EOK on success or an error code
    287318 */
    288319errno_t display_window_resize(display_window_t *window, gfx_coord2_t *offs,
Note: See TracChangeset for help on using the changeset viewer.