Changeset 983052c in mainline
- Timestamp:
- 2023-10-10T12:30:54Z (15 months ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bd2fab5
- Parents:
- 9bec33a
- git-author:
- Jiri Svoboda <jiri@…> (2023-10-09 18:30:06)
- git-committer:
- Jiri Svoboda <jiri@…> (2023-10-10 12:30:54)
- Location:
- uspace
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/taskbar/clock.c
r9bec33a r983052c 322 322 { 323 323 taskbar_clock_t *clock = (taskbar_clock_t *) arg; 324 ui_t *ui; 325 326 ui = ui_window_get_ui(clock->window); 327 ui_lock(ui); 324 328 325 329 fibril_mutex_lock(&clock->lock); 326 (void) taskbar_clock_paint(clock); 330 if (!ui_is_suspended(ui_window_get_ui(clock->window))) 331 (void) taskbar_clock_paint(clock); 327 332 328 333 if (!clock->timer_cleanup) { … … 336 341 337 342 fibril_mutex_unlock(&clock->lock); 343 ui_unlock(ui); 338 344 } 339 345 -
uspace/app/taskbar/wndlist.c
r9bec33a r983052c 254 254 wndlist_set_entry_rect(wndlist, entry); 255 255 if (paint) 256 return ui_pbutton_paint(entry->button);256 return wndlist_paint_entry(entry); 257 257 } 258 258 … … 320 320 wndlist_set_entry_rect(wndlist, e); 321 321 if (paint) { 322 rc = ui_pbutton_paint(e->button);322 rc = wndlist_paint_entry(e); 323 323 if (rc != EOK) 324 324 return rc; … … 402 402 ui_pbutton_set_light(entry->button, active); 403 403 404 rc = ui_pbutton_paint(entry->button);404 rc = wndlist_paint_entry(entry); 405 405 if (rc != EOK) 406 406 return rc; 407 407 408 return wndlist_repaint(wndlist);408 return EOK; 409 409 } 410 410 … … 470 470 } 471 471 472 /** Unpaint window list entry.472 /** Paint window list entry. 473 473 * 474 474 * @param entry Window list entry 475 475 * @return EOK on success or an error code 476 476 */ 477 errno_t wndlist_paint_entry(wndlist_entry_t *entry) 478 { 479 ui_t *ui; 480 481 ui = ui_window_get_ui(entry->wndlist->window); 482 if (ui_is_suspended(ui)) 483 return EOK; 484 485 return ui_pbutton_paint(entry->button); 486 } 487 488 /** Unpaint window list entry. 489 * 490 * @param entry Window list entry 491 * @return EOK on success or an error code 492 */ 477 493 errno_t wndlist_unpaint_entry(wndlist_entry_t *entry) 478 494 { 479 495 errno_t rc; 496 ui_t *ui; 480 497 gfx_context_t *gc; 481 498 ui_resource_t *res; 482 499 gfx_color_t *color; 483 500 501 ui = ui_window_get_ui(entry->wndlist->window); 484 502 gc = ui_window_get_gc(entry->wndlist->window); 485 503 res = ui_window_get_res(entry->wndlist->window); 486 504 color = ui_resource_get_wnd_face_color(res); 487 505 506 if (ui_is_suspended(ui)) 507 return EOK; 508 488 509 rc = gfx_set_color(gc, color); 489 510 if (rc != EOK) … … 510 531 wndlist_t *wndlist = (wndlist_t *)arg; 511 532 wndmgt_window_info_t *winfo = NULL; 533 ui_t *ui; 512 534 errno_t rc; 535 536 ui = ui_window_get_ui(wndlist->window); 537 ui_lock(ui); 513 538 514 539 rc = wndmgt_get_window_info(wndlist->wndmgt, wnd_id, &winfo); … … 526 551 527 552 wndmgt_free_window_info(winfo); 553 ui_unlock(ui); 528 554 return; 529 555 error: 530 556 if (winfo != NULL) 531 557 wndmgt_free_window_info(winfo); 558 ui_unlock(ui); 532 559 } 533 560 … … 541 568 wndlist_t *wndlist = (wndlist_t *)arg; 542 569 wndlist_entry_t *entry; 570 ui_t *ui; 571 572 ui = ui_window_get_ui(wndlist->window); 573 ui_lock(ui); 543 574 544 575 entry = wndlist_entry_by_id(wndlist, wnd_id); 545 if (entry == NULL) 576 if (entry == NULL) { 577 ui_unlock(ui); 546 578 return; 579 } 547 580 548 581 (void) wndlist_remove(wndlist, entry, true); 582 ui_unlock(ui); 549 583 } 550 584 … … 559 593 wndmgt_window_info_t *winfo = NULL; 560 594 wndlist_entry_t *entry; 595 ui_t *ui; 561 596 errno_t rc; 562 597 598 ui = ui_window_get_ui(wndlist->window); 599 ui_lock(ui); 600 563 601 entry = wndlist_entry_by_id(wndlist, wnd_id); 564 if (entry == NULL) 602 if (entry == NULL) { 603 ui_unlock(ui); 565 604 return; 605 } 566 606 567 607 rc = wndmgt_get_window_info(wndlist->wndmgt, wnd_id, &winfo); 568 if (rc != EOK) 608 if (rc != EOK) { 609 ui_unlock(ui); 569 610 return; 611 } 570 612 571 613 (void) wndlist_update(wndlist, entry, winfo->caption, 572 614 winfo->nfocus != 0); 573 615 wndmgt_free_window_info(winfo); 616 ui_unlock(ui); 574 617 } 575 618 … … 660 703 errno_t wndlist_repaint(wndlist_t *wndlist) 661 704 { 705 if (ui_is_suspended(ui_window_get_ui(wndlist->window))) 706 return EOK; 707 662 708 return ui_window_paint(wndlist->window); 663 709 } -
uspace/app/taskbar/wndlist.h
r9bec33a r983052c 63 63 extern size_t wndlist_count(wndlist_t *); 64 64 extern errno_t wndlist_repaint(wndlist_t *); 65 extern errno_t wndlist_paint_entry(wndlist_entry_t *); 65 66 extern errno_t wndlist_unpaint_entry(wndlist_entry_t *); 66 67 -
uspace/lib/ui/include/ui/ui.h
r9bec33a r983052c 57 57 extern errno_t ui_suspend(ui_t *); 58 58 extern errno_t ui_resume(ui_t *); 59 extern bool ui_is_suspended(ui_t *); 59 60 extern void ui_lock(ui_t *); 60 61 extern void ui_unlock(ui_t *); -
uspace/lib/ui/private/ui.h
r9bec33a r983052c 61 61 /** Output owned by UI, clean up when destroying UI */ 62 62 bool myoutput; 63 /** @c true iff UI is suspended */ 64 bool suspended; 63 65 /** @c true if terminating */ 64 66 bool quit; -
uspace/lib/ui/src/ui.c
r9bec33a r983052c 338 338 switch (event->type) { 339 339 case CEV_KEY: 340 ui_lock(ui); 340 341 ui_window_send_kbd(awnd, &event->ev.key); 342 ui_unlock(ui); 341 343 break; 342 344 case CEV_POS: … … 348 350 claim = ui_wdecor_pos_event(awnd->wdecor, &pos); 349 351 /* Note: If event is claimed, awnd might not be valid anymore */ 350 if (claim == ui_unclaimed) 352 if (claim == ui_unclaimed) { 353 ui_lock(ui); 351 354 ui_window_send_pos(awnd, &pos); 355 ui_unlock(ui); 356 } 352 357 353 358 break; … … 454 459 errno_t ui_suspend(ui_t *ui) 455 460 { 456 if (ui->cgc == NULL) 461 errno_t rc; 462 463 assert(!ui->suspended); 464 465 if (ui->cgc == NULL) { 466 ui->suspended = true; 457 467 return EOK; 468 } 458 469 459 470 (void) console_set_caption(ui->console, ""); 460 return console_gc_suspend(ui->cgc); 471 rc = console_gc_suspend(ui->cgc); 472 if (rc != EOK) 473 return rc; 474 475 ui->suspended = true; 476 return EOK; 461 477 } 462 478 … … 477 493 cons_event_t ev; 478 494 479 if (ui->cgc == NULL) 495 assert(ui->suspended); 496 497 if (ui->cgc == NULL) { 498 ui->suspended = false; 480 499 return EOK; 500 } 481 501 482 502 rc = console_get_pos(ui->console, &col, &row); … … 510 530 return rc; 511 531 532 ui->suspended = false; 533 512 534 awnd = ui_window_get_active(ui); 513 535 if (awnd != NULL) 514 536 (void) console_set_caption(ui->console, awnd->wdecor->caption); 515 537 516 return gfx_cursor_set_visible(console_gc_get_ctx(ui->cgc), false); 538 rc = gfx_cursor_set_visible(console_gc_get_ctx(ui->cgc), false); 539 if (rc != EOK) 540 return rc; 541 542 return EOK; 543 } 544 545 /** Determine if UI is suspended. 546 * 547 * @param ui UI 548 * @return @c true iff UI is suspended 549 */ 550 bool ui_is_suspended(ui_t *ui) 551 { 552 return ui->suspended; 517 553 } 518 554 -
uspace/lib/ui/test/ui.c
r9bec33a r983052c 1 1 /* 2 * Copyright (c) 202 2Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 69 69 } 70 70 71 /** ui_suspend() / ui_resume() do nothing if we don't have a console */ 71 /** ui_suspend() / ui_resume() do nothing if we don't have a console, 72 * ui_is_suspended() returns suspend status 73 */ 72 74 PCUT_TEST(suspend_resume) 73 75 { … … 79 81 PCUT_ASSERT_NOT_NULL(ui); 80 82 83 PCUT_ASSERT_FALSE(ui_is_suspended(ui)); 84 81 85 rc = ui_suspend(ui); 82 86 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 87 88 PCUT_ASSERT_TRUE(ui_is_suspended(ui)); 89 83 90 rc = ui_resume(ui); 84 91 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 92 93 PCUT_ASSERT_FALSE(ui_is_suspended(ui)); 85 94 86 95 ui_destroy(ui);
Note:
See TracChangeset
for help on using the changeset viewer.