Changes in / [a3086a4:9a664b6d] in mainline


Ignore:
File:
1 edited

Legend:

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

    ra3086a4 r9a664b6d  
    11/*
    2  * Copyright (c) 2024 Jiri Svoboda
     2 * Copyright (c) 2023 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 *pwindow;
    513         ds_window_t *cwindow;
     512        ds_window_t *wnd;
    514513        errno_t rc;
    515514
    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) {
     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) {
    536535                /* Moving over a window */
    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;
     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                }
    542547        } else {
    543548                /* Not over a window */
    544                 ds_seat_set_client_cursor(seat,
    545                     seat->display->cursor[dcurs_arrow]);
     549                ds_seat_set_client_cursor(seat, seat->display->cursor[dcurs_arrow]);
    546550        }
    547551
    548552        /* Click outside popup window */
    549         if (event->type == POS_PRESS && pwindow != seat->popup) {
     553        if (event->type == POS_PRESS && wnd != seat->popup) {
    550554                /* Close popup window */
    551555                ds_seat_set_popup(seat, NULL);
Note: See TracChangeset for help on using the changeset viewer.