Changeset 5d62130 in mainline for uspace/srv
- Timestamp:
- 2022-11-13T10:56:43Z (3 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a130983
- Parents:
- a5c7b865
- Location:
- uspace/srv/hid/display
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/display.c
ra5c7b865 r5d62130 313 313 } 314 314 315 /** Add window to window list. 316 * 317 * Topmost windows are enlisted before any other window. Non-topmost 318 * windows are enlisted before any other non-topmost window. 319 * 320 * @param display Display 321 * @param wnd Window 322 */ 323 void ds_display_enlist_window(ds_display_t *display, ds_window_t *wnd) 324 { 325 ds_window_t *w; 326 327 assert(wnd->display == display); 328 assert(!link_used(&wnd->ldwindows)); 329 330 if ((wnd->flags & wndf_topmost) == 0) { 331 /* Find the first non-topmost window */ 332 w = ds_display_first_window(display); 333 while (w != NULL && (w->flags & wndf_topmost) != 0) 334 w = ds_display_next_window(w); 335 336 if (w != NULL) 337 list_insert_before(&wnd->ldwindows, &w->ldwindows); 338 else 339 list_append(&wnd->ldwindows, &display->windows); 340 } else { 341 /* Insert at the beginning */ 342 list_prepend(&wnd->ldwindows, &display->windows); 343 } 344 345 } 346 315 347 /** Add window to display. 316 348 * … … 326 358 327 359 wnd->display = display; 328 list_prepend(&wnd->ldwindows, &display->windows);360 ds_display_enlist_window(display, wnd); 329 361 330 362 /* Notify window managers about the new window */ … … 369 401 370 402 list_remove(&wnd->ldwindows); 371 list_prepend(&wnd->ldwindows, &wnd->display->windows);403 ds_display_enlist_window(wnd->display, wnd); 372 404 } 373 405 -
uspace/srv/hid/display/display.h
ra5c7b865 r5d62130 67 67 extern ds_window_t *ds_display_find_window(ds_display_t *, ds_wnd_id_t); 68 68 extern ds_window_t *ds_display_window_by_pos(ds_display_t *, gfx_coord2_t *); 69 extern void ds_display_enlist_window(ds_display_t *, ds_window_t *); 69 70 extern void ds_display_add_window(ds_display_t *, ds_window_t *); 70 71 extern void ds_display_remove_window(ds_window_t *); -
uspace/srv/hid/display/test/display.c
ra5c7b865 r5d62130 195 195 } 196 196 197 /** Test ds_display_enlist_window() */ 198 PCUT_TEST(display_enlist_window) 199 { 200 ds_display_t *disp; 201 ds_client_t *client; 202 ds_seat_t *seat; 203 ds_window_t *w0; 204 ds_window_t *w1; 205 ds_window_t *w2; 206 ds_window_t *w3; 207 ds_window_t *w; 208 display_wnd_params_t params; 209 bool called_cb = false; 210 errno_t rc; 211 212 rc = ds_display_create(NULL, df_none, &disp); 213 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 214 215 rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client); 216 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 217 218 rc = ds_seat_create(disp, &seat); 219 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 220 221 display_wnd_params_init(¶ms); 222 params.rect.p0.x = params.rect.p0.y = 0; 223 params.rect.p1.x = params.rect.p1.y = 100; 224 225 /* Regular windows */ 226 227 rc = ds_window_create(client, ¶ms, &w0); 228 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 229 230 rc = ds_window_create(client, ¶ms, &w1); 231 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 232 233 /* Topmost windows */ 234 235 params.flags |= wndf_topmost; 236 237 rc = ds_window_create(client, ¶ms, &w2); 238 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 239 240 rc = ds_window_create(client, ¶ms, &w3); 241 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 242 243 /* Delist w1 and w2 */ 244 list_remove(&w1->ldwindows); 245 list_remove(&w2->ldwindows); 246 247 /* Enlist the windows back and check their order */ 248 ds_display_enlist_window(disp, w1); 249 ds_display_enlist_window(disp, w2); 250 251 w = ds_display_first_window(disp); 252 PCUT_ASSERT_EQUALS(w2, w); 253 w = ds_display_next_window(w); 254 PCUT_ASSERT_EQUALS(w3, w); 255 w = ds_display_next_window(w); 256 PCUT_ASSERT_EQUALS(w1, w); 257 w = ds_display_next_window(w); 258 PCUT_ASSERT_EQUALS(w0, w); 259 w = ds_display_next_window(w); 260 PCUT_ASSERT_EQUALS(NULL, w); 261 262 ds_window_destroy(w0); 263 ds_window_destroy(w1); 264 ds_window_destroy(w2); 265 ds_window_destroy(w3); 266 ds_seat_destroy(seat); 267 ds_client_destroy(client); 268 ds_display_destroy(disp); 269 } 270 197 271 /** Test ds_display_window_to_top() */ 198 272 PCUT_TEST(display_window_to_top)
Note:
See TracChangeset
for help on using the changeset viewer.