Changeset 4645b2c in mainline for uspace/lib/gui/window.c
- Timestamp:
- 2020-01-29T15:36:37Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3275736
- Parents:
- f5191b4
- git-author:
- Jiri Svoboda <jiri@…> (2020-01-28 19:36:08)
- git-committer:
- Jiri Svoboda <jiri@…> (2020-01-29 15:36:37)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/gui/window.c
rf5191b4 r4645b2c 48 48 #include <adt/list.h> 49 49 50 #include <async.h>51 50 #include <loc.h> 52 51 … … 56 55 #include <draw/drawctx.h> 57 56 #include <draw/surface.h> 57 #include <display.h> 58 58 59 59 #include "common.h" … … 283 283 flags |= btn_left ? GF_RESIZE_X : GF_SCALE_X; 284 284 flags |= btn_left ? GF_RESIZE_Y : GF_SCALE_Y; 285 win_grab(widget->window->osess, event.pos_id, flags);285 //win_grab(widget->window->osess, event.pos_id, flags); 286 286 } else if (bottom && left && allowed_button) { 287 287 window_grab_flags_t flags = GF_EMPTY; … … 289 289 flags |= btn_left ? GF_RESIZE_X : GF_SCALE_X; 290 290 flags |= btn_left ? GF_RESIZE_Y : GF_SCALE_Y; 291 win_grab(widget->window->osess, event.pos_id, flags);291 //win_grab(widget->window->osess, event.pos_id, flags); 292 292 } else if (bottom && right && allowed_button) { 293 293 window_grab_flags_t flags = GF_EMPTY; 294 294 flags |= btn_left ? GF_RESIZE_X : GF_SCALE_X; 295 295 flags |= btn_left ? GF_RESIZE_Y : GF_SCALE_Y; 296 win_grab(widget->window->osess, event.pos_id, flags);296 //win_grab(widget->window->osess, event.pos_id, flags); 297 297 } else if (top && right && allowed_button) { 298 298 window_grab_flags_t flags = GF_EMPTY; … … 300 300 flags |= btn_left ? GF_RESIZE_X : GF_SCALE_X; 301 301 flags |= btn_left ? GF_RESIZE_Y : GF_SCALE_Y; 302 win_grab(widget->window->osess, event.pos_id, flags);302 //win_grab(widget->window->osess, event.pos_id, flags); 303 303 } else if (top && allowed_button) { 304 304 window_grab_flags_t flags = GF_EMPTY; 305 305 flags |= GF_MOVE_Y; 306 306 flags |= btn_left ? GF_RESIZE_Y : GF_SCALE_Y; 307 win_grab(widget->window->osess, event.pos_id, flags);307 //win_grab(widget->window->osess, event.pos_id, flags); 308 308 } else if (left && allowed_button) { 309 309 window_grab_flags_t flags = GF_EMPTY; 310 310 flags |= GF_MOVE_X; 311 311 flags |= btn_left ? GF_RESIZE_X : GF_SCALE_X; 312 win_grab(widget->window->osess, event.pos_id, flags);312 //win_grab(widget->window->osess, event.pos_id, flags); 313 313 } else if (bottom && allowed_button) { 314 314 window_grab_flags_t flags = GF_EMPTY; 315 315 flags |= btn_left ? GF_RESIZE_Y : GF_SCALE_Y; 316 win_grab(widget->window->osess, event.pos_id, flags);316 //win_grab(widget->window->osess, event.pos_id, flags); 317 317 } else if (right && allowed_button) { 318 318 window_grab_flags_t flags = GF_EMPTY; 319 319 flags |= btn_left ? GF_RESIZE_X : GF_SCALE_X; 320 win_grab(widget->window->osess, event.pos_id, flags);320 //win_grab(widget->window->osess, event.pos_id, flags); 321 321 } else if (close && btn_left) { 322 win_close_request(widget->window->osess);322 //win_close_request(widget->window->osess); 323 323 } else if (header && btn_left) { 324 324 window_grab_flags_t flags = GF_EMPTY; 325 325 flags |= GF_MOVE_X; 326 326 flags |= GF_MOVE_Y; 327 win_grab(widget->window->osess, event.pos_id, flags);327 //win_grab(widget->window->osess, event.pos_id, flags); 328 328 } else { 329 329 list_foreach(widget->children, link, widget_t, child) { … … 370 370 sysarg_t width, sysarg_t height, window_placement_flags_t placement_flags) 371 371 { 372 gfx_bitmap_params_t params; 373 gfx_bitmap_alloc_t alloc; 374 372 375 if (width < 2 * border_thickness + header_min_width) { 373 win_damage(win->osess, 0, 0, 0, 0);376 //win_damage(win->osess, 0, 0, 0, 0); 374 377 return; 375 378 } 376 379 377 380 if (height < 2 * border_thickness + header_height) { 378 win_damage(win->osess, 0, 0, 0, 0);381 //win_damage(win->osess, 0, 0, 0, 0); 379 382 return; 380 383 } … … 386 389 return; 387 390 391 gfx_bitmap_t *new_bitmap = NULL; 392 393 params.rect.p0.x = 0; 394 params.rect.p0.y = 0; 395 params.rect.p1.x = width; 396 params.rect.p1.y = height; 397 398 alloc.pitch = width * sizeof(uint32_t); 399 alloc.off0 = 0; 400 alloc.pixels = surface_direct_access(new_surface); 401 402 errno_t rc = gfx_bitmap_create(win->gc, ¶ms, &alloc, &new_bitmap); 403 if (rc != EOK) { 404 surface_destroy(new_surface); 405 return; 406 } 407 388 408 /* Switch new and old surface. */ 389 409 fibril_mutex_lock(&win->guard); 390 410 surface_t *old_surface = win->surface; 411 gfx_bitmap_t *old_bitmap = win->bitmap; 391 412 win->surface = new_surface; 413 win->bitmap = new_bitmap; 392 414 fibril_mutex_unlock(&win->guard); 393 415 … … 403 425 404 426 /* Inform compositor about new surface. */ 405 errno_t rc = win_resize(win->osess, offset_x, offset_y, width, height, 406 placement_flags, surface_direct_access(new_surface)); 427 // errno_t rc = win_resize(win->osess, offset_x, offset_y, width, height, 428 // placement_flags, surface_direct_access(new_surface)); 429 rc = EOK; 407 430 408 431 if (rc != EOK) { … … 429 452 surface_destroy(new_surface); 430 453 } else { 454 if (old_bitmap != NULL) 455 gfx_bitmap_destroy(old_bitmap); 431 456 /* Deallocate old surface. */ 432 457 if (old_surface) 433 458 surface_destroy(old_surface); 459 460 (void) gfx_bitmap_render(win->bitmap, NULL, NULL); 434 461 } 435 462 } … … 443 470 { 444 471 sysarg_t x, y, width, height; 472 gfx_rect_t rect; 445 473 fibril_mutex_lock(&win->guard); 446 474 surface_get_damaged_region(win->surface, &x, &y, &width, &height); … … 448 476 fibril_mutex_unlock(&win->guard); 449 477 478 450 479 if (width > 0 && height > 0) { 451 480 /* Notify compositor. */ 452 win_damage(win->osess, x, y, width, height); 481 //win_damage(win->osess, x, y, width, height); 482 483 rect.p0.x = x; 484 rect.p0.y = y; 485 rect.p1.x = x + width; 486 rect.p1.y = y + height; 487 488 printf("render damaged region: %d,%d,%d,%d,\n", 489 (int)x,(int)y,(int)width,(int)height); 490 (void) gfx_bitmap_render(win->bitmap, &rect, NULL); 453 491 } 454 492 } … … 472 510 win->focus = NULL; 473 511 474 win_close(win->osess); 475 async_hangup(win->isess); 476 async_hangup(win->osess); 512 display_window_destroy(win->dwindow); 513 display_close(win->display); 477 514 478 515 while (!list_empty(&win->events.list)) { … … 562 599 static errno_t fetch_input(void *arg) 563 600 { 564 errno_t rc;565 bool terminate = false;566 window_t *win = (window_t *) arg;567 568 while (true) {601 // errno_t rc; 602 // bool terminate = false; 603 // window_t *win = (window_t *) arg; 604 605 /* while (true) { 569 606 window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t)); 570 607 … … 587 624 } 588 625 } 589 626 */ 590 627 return 0; 591 628 } … … 616 653 win->surface = NULL; 617 654 618 service_id_t reg_dsid; 619 errno_t rc = loc_service_get_id(winreg, ®_dsid, 0); 655 errno_t rc = display_open(winreg, &win->display); 620 656 if (rc != EOK) { 621 657 free(win); … … 623 659 } 624 660 625 async_sess_t *reg_sess = 626 loc_service_connect(reg_dsid, INTERFACE_COMPOSITOR, 0); 627 if (reg_sess == NULL) { 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); 628 673 free(win); 629 674 return NULL; 630 675 } 631 676 632 service_id_t in_dsid; 633 service_id_t out_dsid; 634 rc = win_register(reg_sess, flags, &in_dsid, &out_dsid); 635 async_hangup(reg_sess); 677 rc = display_window_get_gc(win->dwindow, &win->gc); 636 678 if (rc != EOK) { 637 free(win); 638 return NULL; 639 } 640 641 win->osess = loc_service_connect(out_dsid, INTERFACE_COMPOSITOR, 0); 642 if (win->osess == NULL) { 643 free(win); 644 return NULL; 645 } 646 647 win->isess = loc_service_connect(in_dsid, INTERFACE_COMPOSITOR, 0); 648 if (win->isess == NULL) { 649 async_hangup(win->osess); 679 (void) display_window_destroy(win->dwindow); 680 display_close(win->display); 650 681 free(win); 651 682 return NULL; … … 746 777 { 747 778 /* Request compositor to init closing cascade. */ 748 win_close_request(win->osess);779 //win_close_request(win->osess); 749 780 } 750 781
Note:
See TracChangeset
for help on using the changeset viewer.