Ignore:
File:
1 edited

Legend:

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

    r8edec53 rca9aa89  
    11/*
    2  * Copyright (c) 2021 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    9090void ds_seat_set_focus(ds_seat_t *seat, ds_window_t *wnd)
    9191{
     92        errno_t rc;
     93
    9294        if (wnd == seat->focus) {
    9395                /* Focus is not changing */
    9496                return;
     97        }
     98
     99        if (wnd != NULL) {
     100                rc = ds_window_unminimize(wnd);
     101                if (rc != EOK)
     102                        return;
    95103        }
    96104
     
    130138/** Evacuate seat references to window.
    131139 *
    132  * If seat's focus is @a wnd, it will be set to a different window.
     140 * If seat's focus is @a wnd, it will be set to NULL.
    133141 * If seat's popup window is @a wnd, it will be set to NULL.
    134142 *
    135143 * @param seat Seat
    136  * @param wnd Window to evacuate focus from
     144 * @param wnd Window to evacuate references from
    137145 */
    138146void ds_seat_evac_wnd_refs(ds_seat_t *seat, ds_window_t *wnd)
    139147{
    140         ds_window_t *nwnd;
    141 
    142         if (seat->focus == wnd) {
    143                 nwnd = ds_display_prev_window(wnd);
    144                 if (nwnd == NULL)
    145                         nwnd = ds_display_last_window(wnd->display);
    146                 if (nwnd == wnd)
    147                         nwnd = NULL;
    148 
    149                 ds_seat_set_focus(seat, nwnd);
    150         }
     148        if (seat->focus == wnd)
     149                ds_seat_set_focus(seat, NULL);
    151150
    152151        if (seat->popup == wnd)
     
    154153}
    155154
     155/** Unfocus window.
     156 *
     157 * If seat's focus is @a wnd, it will be set to a different window
     158 * that is not minimized, preferably not a system window.
     159 *
     160 * @param seat Seat
     161 * @param wnd Window to remove focus from
     162 */
     163void ds_seat_unfocus_wnd(ds_seat_t *seat, ds_window_t *wnd)
     164{
     165        ds_window_t *nwnd;
     166
     167        if (seat->focus != wnd)
     168                return;
     169
     170        /* Find alternate window that is neither system nor minimized */
     171        nwnd = ds_window_find_alt(wnd, ~(wndf_minimized | wndf_system));
     172
     173        if (nwnd == NULL) {
     174                /* Find alternate window that is not minimized */
     175                nwnd = ds_window_find_alt(wnd, ~wndf_minimized);
     176        }
     177
     178        ds_seat_set_focus(seat, nwnd);
     179}
     180
    156181/** Switch focus to another window.
    157182 *
     
    163188        ds_window_t *nwnd;
    164189
    165         if (seat->focus != NULL)
    166                 nwnd = ds_display_prev_window(seat->focus);
    167         else
    168                 nwnd = NULL;
    169 
    170         if (nwnd == NULL)
    171                 nwnd = ds_display_last_window(seat->display);
    172 
     190        /* Find alternate window that is not a system window */
     191        nwnd = ds_window_find_alt(seat->focus, ~wndf_system);
     192
     193        /* Only switch focus if there is another window */
    173194        if (nwnd != NULL)
    174195                ds_seat_set_focus(seat, nwnd);
     
    364385        if (event->type == PTD_PRESS || event->type == PTD_RELEASE ||
    365386            event->type == PTD_DCLICK) {
    366                 pevent.pos_id = 0;
     387                pevent.pos_id = event->pos_id;
    367388                switch (event->type) {
    368389                case PTD_PRESS:
     
    395416                seat->pntpos = npos;
    396417
    397                 pevent.pos_id = 0;
     418                pevent.pos_id = event->pos_id;
    398419                pevent.type = POS_UPDATE;
    399420                pevent.btn_num = 0;
     
    423444                seat->pntpos = npos;
    424445
    425                 pevent.pos_id = 0;
     446                pevent.pos_id = event->pos_id;
    426447                pevent.type = POS_UPDATE;
    427448                pevent.btn_num = 0;
Note: See TracChangeset for help on using the changeset viewer.