Changeset 6828a56 in mainline for uspace/srv/hid/display/window.c


Ignore:
Timestamp:
2023-01-19T13:51:14Z (15 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5d380b6
Parents:
3be5366
git-author:
Jiri Svoboda <jiri@…> (2023-01-19 19:50:50)
git-committer:
Jiri Svoboda <jiri@…> (2023-01-19 13:51:14)
Message:

Avoid two seats fighting when moving/resizing a window

When two seats have focus on the same window, both pointer's movements
would be delivered to it. Make sure only the seat which started the
move or resize operation affects the operation, otherwise they fight
over it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/display/window.c

    r3be5366 r6828a56  
    656656
    657657        if (event->type == POS_RELEASE) {
    658                 if (wnd->state == dsw_moving) {
     658                /* Finish move/resize if they were started by the same seat */
     659                if (wnd->state == dsw_moving &&
     660                    ds_window_orig_seat(wnd, pos_id)) {
    659661                        ds_window_finish_move(wnd, &pos);
    660662                        return EOK;
    661663                }
    662664
    663                 if (wnd->state == dsw_resizing) {
     665                if (wnd->state == dsw_resizing &&
     666                    ds_window_orig_seat(wnd, pos_id)) {
    664667                        ds_window_finish_resize(wnd, &pos);
    665668                        return EOK;
     
    668671
    669672        if (event->type == POS_UPDATE) {
    670                 if (wnd->state == dsw_moving) {
     673                /* Update move/resize if they were started by the same seat */
     674                if (wnd->state == dsw_moving &&
     675                    ds_window_orig_seat(wnd, pos_id)) {
    671676                        ds_window_update_move(wnd, &pos);
    672677                        return EOK;
    673678                }
    674679
    675                 if (wnd->state == dsw_resizing) {
     680                if (wnd->state == dsw_resizing &&
     681                    ds_window_orig_seat(wnd, pos_id)) {
    676682                        ds_window_update_resize(wnd, &pos);
    677683                        return EOK;
     
    11251131}
    11261132
     1133/** Determine if input device belongs to the same seat as the original device.
     1134 *
     1135 * Compare the seat ownning @a idev_id with the seat owning @a wnd->orig_pos_id
     1136 * (the device that started the window move or resize).
     1137 *
     1138 * This is used to make sure that, when two seats focus the same window,
     1139 * only devices owned by the seat that started the resize or move can
     1140 * affect it. Otherwise moving the other pointer(s) would disrupt the
     1141 * resize or move operation.
     1142 *
     1143 * @param wnd Window (that is currently being resized or moved)
     1144 * @param idev_id Input device ID
     1145 * @return @c true iff idev_id is owned by the same seat as the input
     1146 *         device that started the resize or move
     1147 */
     1148bool ds_window_orig_seat(ds_window_t *wnd, sysarg_t idev_id)
     1149{
     1150        ds_seat_t *orig_seat;
     1151        ds_seat_t *seat;
     1152
     1153        /* Window must be in state such that wnd->orig_pos_id is valid */
     1154        assert(wnd->state == dsw_moving || wnd->state == dsw_resizing);
     1155
     1156        orig_seat = ds_display_seat_by_idev(wnd->display, wnd->orig_pos_id);
     1157        seat = ds_display_seat_by_idev(wnd->display, idev_id);
     1158
     1159        return seat == orig_seat;
     1160}
     1161
    11271162/** Window memory GC invalidate callback.
    11281163 *
Note: See TracChangeset for help on using the changeset viewer.