Changeset e3997a8 in mainline


Ignore:
Timestamp:
2024-06-29T10:37:43Z (3 weeks ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
560408a, a215c4f, b6b1a27, dc5647e, fac17b3
Parents:
af3235d
git-author:
Jiri Svoboda <jiri@…> (2024-06-29 10:27:24)
git-committer:
Jiri Svoboda <jiri@…> (2024-06-29 10:37:43)
Message:

Do not send press event to focused window obscured by popup window

File:
1 edited

Legend:

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

    raf3235d re3997a8  
    11/*
    2  * Copyright (c) 2023 Jiri Svoboda
     2 * Copyright (c) 2024 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    510510errno_t ds_seat_post_pos_event(ds_seat_t *seat, pos_event_t *event)
    511511{
    512         ds_window_t *wnd;
     512        ds_window_t *pwindow;
     513        ds_window_t *cwindow;
    513514        errno_t rc;
    514515
    515         wnd = ds_display_window_by_pos(seat->display, &seat->pntpos);
    516 
    517         /* Deliver event to popup window. */
    518         if (seat->popup != NULL && event->type != POS_PRESS) {
    519                 rc = ds_window_post_pos_event(seat->popup, event);
    520                 if (rc != EOK)
    521                         return rc;
    522         }
    523 
    524         if (seat->focus != wnd && seat->focus != NULL) {
    525                 rc = ds_window_post_pos_event(seat->focus, event);
    526                 if (rc != EOK)
    527                         return rc;
    528 
    529                 /* Only deliver release events to the focused window */
    530                 if (event->type == POS_RELEASE)
    531                         return EOK;
    532         }
    533 
    534         if (wnd != NULL) {
     516        /* Window under pointer */
     517        pwindow = ds_display_window_by_pos(seat->display, &seat->pntpos);
     518
     519        /* Current window: popup or focused */
     520        cwindow = seat->popup;
     521        if (cwindow == NULL)
     522                cwindow = seat->focus;
     523
     524        /*
     525         * Deliver move and release event to current window if different
     526         * from pwindow
     527         */
     528        if (event->type != POS_PRESS && cwindow != NULL &&
     529            cwindow != pwindow) {
     530                rc = ds_window_post_pos_event(cwindow, event);
     531                if (rc != EOK)
     532                        return rc;
     533        }
     534
     535        if (pwindow != NULL) {
    535536                /* Moving over a window */
    536                 ds_seat_set_client_cursor(seat, wnd->cursor);
    537 
    538                 /*
    539                  * Only deliver event if we didn't already deliver it
    540                  * to the same window above.
    541                  */
    542                 if (wnd != seat->popup || event->type == POS_PRESS) {
    543                         rc = ds_window_post_pos_event(wnd, event);
    544                         if (rc != EOK)
    545                                 return rc;
    546                 }
     537                ds_seat_set_client_cursor(seat, pwindow->cursor);
     538
     539                rc = ds_window_post_pos_event(pwindow, event);
     540                if (rc != EOK)
     541                        return rc;
    547542        } else {
    548543                /* Not over a window */
    549                 ds_seat_set_client_cursor(seat, seat->display->cursor[dcurs_arrow]);
     544                ds_seat_set_client_cursor(seat,
     545                    seat->display->cursor[dcurs_arrow]);
    550546        }
    551547
    552548        /* Click outside popup window */
    553         if (event->type == POS_PRESS && wnd != seat->popup) {
     549        if (event->type == POS_PRESS && pwindow != seat->popup) {
    554550                /* Close popup window */
    555551                ds_seat_set_popup(seat, NULL);
Note: See TracChangeset for help on using the changeset viewer.