Ignore:
File:
1 edited

Legend:

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

    rca9aa89 r8edec53  
    11/*
    2  * Copyright (c) 2023 Jiri Svoboda
     2 * Copyright (c) 2021 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 
    9492        if (wnd == seat->focus) {
    9593                /* Focus is not changing */
    9694                return;
    97         }
    98 
    99         if (wnd != NULL) {
    100                 rc = ds_window_unminimize(wnd);
    101                 if (rc != EOK)
    102                         return;
    10395        }
    10496
     
    138130/** Evacuate seat references to window.
    139131 *
    140  * If seat's focus is @a wnd, it will be set to NULL.
     132 * If seat's focus is @a wnd, it will be set to a different window.
    141133 * If seat's popup window is @a wnd, it will be set to NULL.
    142134 *
    143135 * @param seat Seat
    144  * @param wnd Window to evacuate references from
     136 * @param wnd Window to evacuate focus from
    145137 */
    146138void ds_seat_evac_wnd_refs(ds_seat_t *seat, ds_window_t *wnd)
    147139{
    148         if (seat->focus == wnd)
    149                 ds_seat_set_focus(seat, NULL);
     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        }
    150151
    151152        if (seat->popup == wnd)
     
    153154}
    154155
    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  */
    163 void ds_seat_unfocus_wnd(ds_seat_t *seat, ds_window_t *wnd)
     156/** Switch focus to another window.
     157 *
     158 * @param seat Seat
     159 * @param wnd Window to evacuate focus from
     160 */
     161void ds_seat_switch_focus(ds_seat_t *seat)
    164162{
    165163        ds_window_t *nwnd;
    166164
    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 
    181 /** Switch focus to another window.
    182  *
    183  * @param seat Seat
    184  * @param wnd Window to evacuate focus from
    185  */
    186 void ds_seat_switch_focus(ds_seat_t *seat)
    187 {
    188         ds_window_t *nwnd;
    189 
    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 */
     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
    194173        if (nwnd != NULL)
    195174                ds_seat_set_focus(seat, nwnd);
     
    385364        if (event->type == PTD_PRESS || event->type == PTD_RELEASE ||
    386365            event->type == PTD_DCLICK) {
    387                 pevent.pos_id = event->pos_id;
     366                pevent.pos_id = 0;
    388367                switch (event->type) {
    389368                case PTD_PRESS:
     
    416395                seat->pntpos = npos;
    417396
    418                 pevent.pos_id = event->pos_id;
     397                pevent.pos_id = 0;
    419398                pevent.type = POS_UPDATE;
    420399                pevent.btn_num = 0;
     
    444423                seat->pntpos = npos;
    445424
    446                 pevent.pos_id = event->pos_id;
     425                pevent.pos_id = 0;
    447426                pevent.type = POS_UPDATE;
    448427                pevent.btn_num = 0;
Note: See TracChangeset for help on using the changeset viewer.