Changeset 0da03df in mainline for uspace/srv/hid/display/seat.c


Ignore:
Timestamp:
2020-12-10T10:27:07Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
442210e
Parents:
08f345f
git-author:
Jiri Svoboda <jiri@…> (2020-12-09 18:26:57)
git-committer:
Jiri Svoboda <jiri@…> (2020-12-10 10:27:07)
Message:

Distinguish between focus switching and evacuation

It's the same thing if there are at least two windows. With just
one window, switching focus should do nothing. Evacuation should
lead to no window being focused. (Fixes crash when pressing
Alt-Shift/Ctrl-Shift with just one window left).

File:
1 edited

Legend:

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

    r08f345f r0da03df  
    128128}
    129129
     130/** Switch focus to another window.
     131 *
     132 * @param seat Seat
     133 * @param wnd Window to evacuate focus from
     134 */
     135void ds_seat_switch_focus(ds_seat_t *seat)
     136{
     137        ds_window_t *nwnd;
     138
     139        if (seat->focus != NULL)
     140                nwnd = ds_display_prev_window(seat->focus);
     141        else
     142                nwnd = NULL;
     143
     144        if (nwnd == NULL)
     145                nwnd = ds_display_last_window(seat->display);
     146
     147        if (nwnd != NULL)
     148                ds_seat_set_focus(seat, nwnd);
     149}
     150
    130151/** Post keyboard event to the seat's focused window.
    131152 *
     
    143164        if (event->type == KEY_PRESS && alt_or_shift && event->key == KC_TAB) {
    144165                /* On Alt-Tab or Shift-Tab, switch focus to next window */
    145                 ds_seat_evac_focus(seat, seat->focus);
     166                ds_seat_switch_focus(seat);
    146167                return EOK;
    147168        }
     
    389410
    390411        wnd = ds_display_window_by_pos(seat->display, &seat->pntpos);
    391 
    392         if (seat->focus != wnd) {
     412        if (seat->focus != wnd && seat->focus != NULL) {
    393413                rc = ds_window_post_pos_event(seat->focus, event);
    394414                if (rc != EOK)
Note: See TracChangeset for help on using the changeset viewer.