Changeset 0b6fad9 in mainline


Ignore:
Timestamp:
2023-08-10T14:25:09Z (9 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
46bd63c9
Parents:
24be331e
git-author:
Jiri Svoboda <jiri@…> (2023-08-09 17:24:57)
git-committer:
Jiri Svoboda <jiri@…> (2023-08-10 14:25:09)
Message:

Avoid null pointer dereference when switching focus

I hit this when I created a new seat and there was no focused window.
It could probably also happen e.g. if there are no windows.
Now we also set focus for a newly created seat.

File:
1 edited

Legend:

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

    r24be331e r0b6fad9  
    8888        seat->client_cursor = display->cursor[dcurs_arrow];
    8989        seat->wm_cursor = NULL;
     90        seat->focus = ds_display_first_window(display);
    9091
    9192        *rseat = seat;
     
    223224        ds_window_t *nwnd;
    224225
    225         /* Find alternate window that is not a system window */
    226         nwnd = ds_window_find_next(seat->focus, ~wndf_system);
     226        if (seat->focus != NULL) {
     227                /* Find alternate window that is not a system window */
     228                nwnd = ds_window_find_next(seat->focus, ~wndf_system);
     229        } else {
     230                /* Currently no focus. Focus topmost window. */
     231                nwnd = ds_display_first_window(seat->display);
     232        }
    227233
    228234        /* Only switch focus if there is another window */
Note: See TracChangeset for help on using the changeset viewer.