Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset ededdc4 in mainline


Ignore:
Timestamp:
2023-01-05T20:17:32Z (4 weeks ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
ca9aa89
Parents:
17c0f5d
Message:

Use ds_window_unfocus() when destroying a window

Location:
uspace/srv/hid/display
Files:
3 edited

Legend:

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

    r17c0f5d rededdc4  
    138138/** Evacuate seat references to window.
    139139 *
    140  * 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.
    141141 * If seat's popup window is @a wnd, it will be set to NULL.
    142142 *
     
    146146void ds_seat_evac_wnd_refs(ds_seat_t *seat, ds_window_t *wnd)
    147147{
    148         ds_window_t *nwnd;
    149 
    150         if (seat->focus == wnd) {
    151                 nwnd = ds_display_prev_window(wnd);
    152                 if (nwnd == NULL)
    153                         nwnd = ds_display_last_window(wnd->display);
    154                 if (nwnd == wnd)
    155                         nwnd = NULL;
    156 
    157                 ds_seat_set_focus(seat, nwnd);
    158         }
     148        if (seat->focus == wnd)
     149                ds_seat_set_focus(seat, NULL);
    159150
    160151        if (seat->popup == wnd)
  • uspace/srv/hid/display/test/seat.c

    r17c0f5d rededdc4  
    9090}
    9191
    92 /** Evacuate focus when another window is available. */
    93 PCUT_TEST(evac_focus_two_windows)
    94 {
    95         ds_display_t *disp;
    96         ds_client_t *client;
    97         ds_seat_t *seat;
    98         ds_window_t *w0;
    99         ds_window_t *w1;
    100         display_wnd_params_t params;
    101         bool called_cb = false;
    102         errno_t rc;
    103 
    104         rc = ds_display_create(NULL, df_none, &disp);
    105         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    106 
    107         rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client);
    108         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    109 
    110         rc = ds_seat_create(disp, &seat);
    111         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    112 
    113         display_wnd_params_init(&params);
    114         params.rect.p0.x = params.rect.p0.y = 0;
    115         params.rect.p1.x = params.rect.p1.y = 1;
    116 
    117         rc = ds_window_create(client, &params, &w1);
    118         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    119 
    120         rc = ds_window_create(client, &params, &w0);
    121         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    122 
    123         ds_seat_set_focus(seat, w1);
    124         PCUT_ASSERT_EQUALS(w1, seat->focus);
    125         PCUT_ASSERT_TRUE(called_cb);
    126         called_cb = false;
    127 
    128         ds_seat_evac_wnd_refs(seat, w1);
    129         PCUT_ASSERT_EQUALS(w0, seat->focus);
    130         PCUT_ASSERT_TRUE(called_cb);
    131 
    132         ds_window_destroy(w0);
    133         ds_window_destroy(w1);
    134         ds_seat_destroy(seat);
    135         ds_client_destroy(client);
    136         ds_display_destroy(disp);
    137 }
    138 
    139 /** Evacuate focus from the only existing window.
     92/** Evacuate focus from window.
    14093 *
    14194 * After evacuating no window should be focused
  • uspace/srv/hid/display/window.c

    r17c0f5d rededdc4  
    183183        disp = wnd->display;
    184184
     185        ds_window_unfocus(wnd);
     186
    185187        ds_client_remove_window(wnd);
    186188        ds_display_remove_window(wnd);
Note: See TracChangeset for help on using the changeset viewer.