Changeset aa2b32c in mainline for uspace/srv/hid/compositor/compositor.c
- Timestamp:
- 2013-04-29T12:44:05Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a269d05
- Parents:
- 06b0211b (diff), 9e7898e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/compositor/compositor.c
r06b0211b raa2b32c 90 90 typedef struct { 91 91 link_t link; 92 atomic_t ref_cnt; 92 93 service_id_t in_dsid; 93 94 service_id_t out_dsid; … … 138 139 } viewport_t; 139 140 141 static desktop_rect_t viewport_bound_rect; 140 142 static FIBRIL_MUTEX_INITIALIZE(viewport_list_mtx); 141 143 static LIST_INITIALIZE(viewport_list); … … 215 217 216 218 link_initialize(&win->link); 219 atomic_set(&win->ref_cnt, 0); 217 220 prodcons_initialize(&win->queue); 218 221 transform_identity(&win->transform); … … 232 235 static void window_destroy(window_t *win) 233 236 { 234 if (win) { 237 if (win && atomic_get(&win->ref_cnt) == 0) { 238 while (!list_empty(&win->queue.list)) { 239 window_event_t *event = (window_event_t *) list_first(&win->queue.list); 240 list_remove(&event->link); 241 free(event); 242 } 243 235 244 if (win->surface) { 236 245 surface_destroy(win->surface); … … 310 319 } 311 320 321 static void comp_restrict_pointers(void) 322 { 323 fibril_mutex_lock(&viewport_list_mtx); 324 325 sysarg_t x_res = coord_origin; 326 sysarg_t y_res = coord_origin; 327 sysarg_t w_res = 0; 328 sysarg_t h_res = 0; 329 330 if (!list_empty(&viewport_list)) { 331 viewport_t *vp = (viewport_t *) list_first(&viewport_list); 332 x_res = vp->pos.x; 333 y_res = vp->pos.y; 334 surface_get_resolution(vp->surface, &w_res, &h_res); 335 } 336 337 list_foreach(viewport_list, link) { 338 viewport_t *vp = list_get_instance(link, viewport_t, link); 339 sysarg_t w_vp, h_vp; 340 surface_get_resolution(vp->surface, &w_vp, &h_vp); 341 rectangle_union( 342 x_res, y_res, w_res, h_res, 343 vp->pos.x, vp->pos.y, w_vp, h_vp, 344 &x_res, &y_res, &w_res, &h_res); 345 } 346 347 viewport_bound_rect.x = x_res; 348 viewport_bound_rect.y = y_res; 349 viewport_bound_rect.w = w_res; 350 viewport_bound_rect.h = h_res; 351 352 fibril_mutex_unlock(&viewport_list_mtx); 353 354 fibril_mutex_lock(&pointer_list_mtx); 355 356 list_foreach(pointer_list, link) { 357 pointer_t *ptr = list_get_instance(link, pointer_t, link); 358 ptr->pos.x = ptr->pos.x > viewport_bound_rect.x ? ptr->pos.x : viewport_bound_rect.x; 359 ptr->pos.y = ptr->pos.y > viewport_bound_rect.y ? ptr->pos.y : viewport_bound_rect.y; 360 ptr->pos.x = ptr->pos.x < viewport_bound_rect.x + viewport_bound_rect.w ? 361 ptr->pos.x : viewport_bound_rect.x + viewport_bound_rect.w; 362 ptr->pos.y = ptr->pos.y < viewport_bound_rect.y + viewport_bound_rect.h ? 363 ptr->pos.y : viewport_bound_rect.y + viewport_bound_rect.h; 364 } 365 366 fibril_mutex_unlock(&pointer_list_mtx); 367 } 368 312 369 static void comp_damage(sysarg_t x_dmg_glob, sysarg_t y_dmg_glob, 313 370 sysarg_t w_dmg_glob, sysarg_t h_dmg_glob) … … 695 752 } 696 753 754 loc_service_unregister(win->in_dsid); 755 loc_service_unregister(win->out_dsid); 756 757 /* In case the client was killed, input fibril of the window might be 758 * still blocked on the condition within comp_window_get_event. */ 759 window_event_t *event_dummy = (window_event_t *) malloc(sizeof(window_event_t)); 760 if (event_dummy) { 761 link_initialize(&event_dummy->link); 762 prodcons_produce(&win->queue, &event_dummy->link); 763 } 764 697 765 /* Calculate damage. */ 698 766 sysarg_t x = 0; … … 706 774 } 707 775 708 /* Release window resources. */709 loc_service_unregister(win->in_dsid);710 loc_service_unregister(win->out_dsid);711 while (!list_empty(&win->queue.list)) {712 list_remove(list_first(&win->queue.list));713 }714 window_destroy(win);715 716 776 comp_damage(x, y, width, height); 717 777 … … 813 873 814 874 if (win) { 875 atomic_inc(&win->ref_cnt); 815 876 async_answer_0(iid, EOK); 816 877 } else { … … 825 886 826 887 if (!IPC_GET_IMETHOD(call)) { 827 async_answer_0(callid, EINVAL); 888 async_answer_0(callid, EOK); 889 atomic_dec(&win->ref_cnt); 890 window_destroy(win); 828 891 return; 829 892 } … … 842 905 843 906 if (!IPC_GET_IMETHOD(call)) { 844 async_answer_0(callid, EINVAL); 907 comp_window_close(win, callid, &call); 908 atomic_dec(&win->ref_cnt); 909 window_destroy(win); 845 910 return; 846 911 } … … 857 922 break; 858 923 case WINDOW_CLOSE: 859 comp_window_close(win, callid, &call); 924 /* Postpone the closing until the phone is hung up to cover 925 * the case when the client is killed abruptly. */ 926 async_answer_0(callid, EOK); 860 927 break; 861 928 case WINDOW_CLOSE_REQUEST: … … 911 978 async_answer_0(iid, EOK); 912 979 980 comp_restrict_pointers(); 913 981 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); 914 982 } … … 956 1024 fibril_mutex_unlock(&viewport_list_mtx); 957 1025 async_answer_0(iid, EOK); 1026 1027 comp_restrict_pointers(); 1028 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); 958 1029 } 959 1030 } … … 1391 1462 surface_get_resolution(pointer->cursor.states[pointer->state], 1392 1463 &cursor_width, &cursor_height); 1464 if (pointer->pos.x + dx < viewport_bound_rect.x) { 1465 dx = -1 * (pointer->pos.x - viewport_bound_rect.x); 1466 } 1467 if (pointer->pos.y + dy < viewport_bound_rect.y) { 1468 dy = -1 * (pointer->pos.y - viewport_bound_rect.y); 1469 } 1470 if (pointer->pos.x + dx > viewport_bound_rect.x + viewport_bound_rect.w) { 1471 dx = (viewport_bound_rect.x + viewport_bound_rect.w - pointer->pos.x); 1472 } 1473 if (pointer->pos.y + dy > viewport_bound_rect.y + viewport_bound_rect.h) { 1474 dy = (viewport_bound_rect.y + viewport_bound_rect.h - pointer->pos.y); 1475 } 1393 1476 pointer->pos.x += dx; 1394 1477 pointer->pos.y += dy; … … 1910 1993 fibril_mutex_unlock(&viewport_list_mtx); 1911 1994 1995 comp_restrict_pointers(); 1912 1996 comp_damage(x, y, width, height); 1913 1997 } else { … … 1962 2046 } 1963 2047 list_prepend(&blue_win->link, &window_list); 1964 1965 window_t *helenos_win = window_create(0, 0); 1966 helenos_win->surface = decode_tga((void *) helenos_tga, helenos_tga_size, 0); 1967 list_prepend(&helenos_win->link, &window_list); 1968 2048 1969 2049 window_t *nameic_win = window_create(0, 0); 1970 2050 nameic_win->surface = decode_tga((void *) nameic_tga, nameic_tga_size, 0); … … 2126 2206 return -1; 2127 2207 } 2128 2208 2209 comp_restrict_pointers(); 2129 2210 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); 2130 2211
Note:
See TracChangeset
for help on using the changeset viewer.