Changeset 62fbb7e in mainline for uspace/lib/gui/window.c
- Timestamp:
- 2014-01-16T20:43:22Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6a3d0c7
- Parents:
- ba02baa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/gui/window.c
rba02baa r62fbb7e 352 352 } 353 353 354 static void handle_signal_event(window_t *win, sig _event_t event)354 static void handle_signal_event(window_t *win, signal_event_t event) 355 355 { 356 356 widget_t *widget = (widget_t *) event.object; … … 363 363 } 364 364 365 static void handle_resize(window_t *win, sysarg_t width, sysarg_t height) 366 { 367 int rc; 368 surface_t *old_surface; 369 surface_t *new_surface; 370 365 static void handle_resize(window_t *win, sysarg_t offset_x, sysarg_t offset_y, 366 sysarg_t width, sysarg_t height, window_placement_flags_t placement_flags) 367 { 371 368 if (width < 2 * border_thickness + header_min_width) { 372 369 win_damage(win->osess, 0, 0, 0, 0); 373 370 return; 374 371 } 375 372 376 373 if (height < 2 * border_thickness + header_height) { 377 374 win_damage(win->osess, 0, 0, 0, 0); 378 375 return; 379 376 } 380 377 381 378 /* Allocate resources for new surface. */ 382 new_surface = surface_create(width, height, NULL, SURFACE_FLAG_SHARED); 383 if (!new_surface) { 379 surface_t *new_surface = surface_create(width, height, NULL, 380 SURFACE_FLAG_SHARED); 381 if (!new_surface) 384 382 return; 385 } 386 383 387 384 /* Switch new and old surface. */ 388 385 fibril_mutex_lock(&win->guard); 389 old_surface = win->surface;386 surface_t *old_surface = win->surface; 390 387 win->surface = new_surface; 391 388 fibril_mutex_unlock(&win->guard); 392 393 /* Let all widgets in the tree alter their position and size. Widgets might 394 * also paint themselves onto the new surface. */ 389 390 /* 391 * Let all widgets in the tree alter their position and size. 392 * Widgets might also paint themselves onto the new surface. 393 */ 395 394 win->root.rearrange(&win->root, 0, 0, width, height); 396 395 397 396 fibril_mutex_lock(&win->guard); 398 397 surface_reset_damaged_region(win->surface); 399 398 fibril_mutex_unlock(&win->guard); 400 399 401 400 /* Inform compositor about new surface. */ 402 rc = win_resize(win->osess,403 width, height, surface_direct_access(new_surface));404 401 int rc = win_resize(win->osess, offset_x, offset_y, width, height, 402 placement_flags, surface_direct_access(new_surface)); 403 405 404 if (rc != EOK) { 406 405 /* Rollback to old surface. Reverse all changes. */ 407 406 408 407 sysarg_t old_width = 0; 409 408 sysarg_t old_height = 0; 410 if (old_surface) {409 if (old_surface) 411 410 surface_get_resolution(old_surface, &old_width, &old_height); 412 } 413 411 414 412 fibril_mutex_lock(&win->guard); 415 413 new_surface = win->surface; 416 414 win->surface = old_surface; 417 415 fibril_mutex_unlock(&win->guard); 418 416 419 417 win->root.rearrange(&win->root, 0, 0, old_width, old_height); 420 418 … … 424 422 fibril_mutex_unlock(&win->guard); 425 423 } 426 424 427 425 surface_destroy(new_surface); 428 return; 429 } 430 431 /* Finally deallocate old surface. */ 432 if (old_surface) { 433 surface_destroy(old_surface); 426 } else { 427 /* Deallocate old surface. */ 428 if (old_surface) 429 surface_destroy(old_surface); 434 430 } 435 431 } … … 513 509 break; 514 510 case ET_SIGNAL_EVENT: 515 handle_signal_event(win, event->data.sig );511 handle_signal_event(win, event->data.signal); 516 512 break; 517 513 case ET_WINDOW_RESIZE: 518 handle_resize(win, event->data.rsz.width, event->data.rsz.height); 514 handle_resize(win, event->data.resize.offset_x, 515 event->data.resize.offset_y, event->data.resize.width, 516 event->data.resize.height, event->data.resize.placement_flags); 519 517 break; 520 518 case ET_WINDOW_FOCUS: … … 590 588 591 589 window_t *window_open(const char *winreg, bool is_main, bool is_decorated, 592 const char *caption , sysarg_t x_offset, sysarg_t y_offset)590 const char *caption) 593 591 { 594 592 window_t *win = (window_t *) malloc(sizeof(window_t)); … … 630 628 service_id_t in_dsid; 631 629 service_id_t out_dsid; 632 rc = win_register(reg_sess, &in_dsid, &out_dsid , x_offset, y_offset);630 rc = win_register(reg_sess, &in_dsid, &out_dsid); 633 631 async_hangup(reg_sess); 634 632 if (rc != EOK) { … … 658 656 } 659 657 660 void window_resize(window_t *win, sysarg_t width, sysarg_t height) 658 void window_resize(window_t *win, sysarg_t offset_x, sysarg_t offset_y, 659 sysarg_t width, sysarg_t height, window_placement_flags_t placement_flags) 661 660 { 662 661 window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t)); … … 664 663 link_initialize(&event->link); 665 664 event->type = ET_WINDOW_RESIZE; 666 event->data.rsz.width = width; 667 event->data.rsz.height = height; 665 event->data.resize.offset_x = offset_x; 666 event->data.resize.offset_y = offset_y; 667 event->data.resize.width = width; 668 event->data.resize.height = height; 669 event->data.resize.placement_flags = placement_flags; 668 670 prodcons_produce(&win->events, &event->link); 669 671 }
Note:
See TracChangeset
for help on using the changeset viewer.