Changeset 3275736 in mainline
- Timestamp:
- 2020-01-30T12:14:37Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 287688f
- Parents:
- 4645b2c
- git-author:
- Jiri Svoboda <jiri@…> (2020-01-29 20:14:25)
- git-committer:
- Jiri Svoboda <jiri@…> (2020-01-30 12:14:37)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/gui/window.c
r4645b2c r3275736 370 370 sysarg_t width, sysarg_t height, window_placement_flags_t placement_flags) 371 371 { 372 display_wnd_params_t wparams; 373 display_window_t *new_window = NULL; 372 374 gfx_bitmap_params_t params; 373 375 gfx_bitmap_alloc_t alloc; 376 gfx_bitmap_t *new_bitmap = NULL; 377 gfx_context_t *new_gc = NULL; 378 errno_t rc; 374 379 375 380 if (width < 2 * border_thickness + header_min_width) { … … 389 394 return; 390 395 391 gfx_bitmap_t *new_bitmap = NULL; 396 display_wnd_params_init(&wparams); 397 wparams.rect.p0.x = 0; 398 wparams.rect.p0.y = 0; 399 wparams.rect.p1.x = width; 400 wparams.rect.p1.y = height; 401 402 rc = display_window_create(win->display, &wparams, NULL, NULL, 403 &new_window); 404 if (rc != EOK) { 405 surface_destroy(new_surface); 406 return; 407 } 408 409 rc = display_window_get_gc(new_window, &new_gc); 410 if (rc != EOK) { 411 display_window_destroy(new_window); 412 surface_destroy(new_surface); 413 return; 414 } 392 415 393 416 params.rect.p0.x = 0; … … 400 423 alloc.pixels = surface_direct_access(new_surface); 401 424 402 errno_t rc = gfx_bitmap_create(win->gc, ¶ms, &alloc, &new_bitmap);425 rc = gfx_bitmap_create(new_gc, ¶ms, &alloc, &new_bitmap); 403 426 if (rc != EOK) { 427 gfx_context_delete(new_gc); 428 display_window_destroy(new_window); 404 429 surface_destroy(new_surface); 405 430 return; … … 410 435 surface_t *old_surface = win->surface; 411 436 gfx_bitmap_t *old_bitmap = win->bitmap; 437 display_window_t *old_window = win->dwindow; 438 gfx_context_t *old_gc = win->gc; 412 439 win->surface = new_surface; 413 440 win->bitmap = new_bitmap; 441 win->dwindow = new_window; 442 win->gc = new_gc; 414 443 fibril_mutex_unlock(&win->guard); 415 444 … … 440 469 new_surface = win->surface; 441 470 win->surface = old_surface; 471 win->bitmap = old_bitmap; 472 win->dwindow = old_window; 473 win->gc = old_gc; 442 474 fibril_mutex_unlock(&win->guard); 443 475 … … 452 484 surface_destroy(new_surface); 453 485 } else { 486 if (old_window != NULL) 487 display_window_destroy(old_window); 488 if (old_gc != NULL) 489 gfx_context_delete(old_gc); 454 490 if (old_bitmap != NULL) 455 491 gfx_bitmap_destroy(old_bitmap); … … 488 524 printf("render damaged region: %d,%d,%d,%d,\n", 489 525 (int)x,(int)y,(int)width,(int)height); 490 (void) gfx_bitmap_render(win->bitmap, &rect, NULL); 526 if (win->bitmap != NULL) 527 (void) gfx_bitmap_render(win->bitmap, &rect, NULL); 491 528 } 492 529 } … … 631 668 window_flags_t flags, const char *caption) 632 669 { 633 window_t *win = (window_t *) malloc(sizeof(window_t));670 window_t *win = (window_t *) calloc(1, sizeof(window_t)); 634 671 if (!win) 635 672 return NULL; … … 659 696 } 660 697 661 display_wnd_params_t params;662 display_wnd_params_init(¶ms);663 664 params.rect.p0.x = 0;665 params.rect.p0.y = 0;666 params.rect.p1.x = 200;667 params.rect.p1.y = 100;668 669 rc = display_window_create(win->display, ¶ms, NULL, NULL,670 &win->dwindow);671 if (rc != EOK) {672 display_close(win->display);673 free(win);674 return NULL;675 }676 677 rc = display_window_get_gc(win->dwindow, &win->gc);678 if (rc != EOK) {679 (void) display_window_destroy(win->dwindow);680 display_close(win->display);681 free(win);682 return NULL;683 }684 698 685 699 if (caption == NULL)
Note:
See TracChangeset
for help on using the changeset viewer.