Changes in uspace/srv/hid/compositor/compositor.c [3b98311:428bd07] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/compositor/compositor.c
r3b98311 r428bd07 90 90 typedef struct { 91 91 link_t link; 92 atomic_t ref_cnt;93 92 service_id_t in_dsid; 94 93 service_id_t out_dsid; … … 139 138 } viewport_t; 140 139 141 static desktop_rect_t viewport_bound_rect;142 140 static FIBRIL_MUTEX_INITIALIZE(viewport_list_mtx); 143 141 static LIST_INITIALIZE(viewport_list); … … 217 215 218 216 link_initialize(&win->link); 219 atomic_set(&win->ref_cnt, 0);220 217 prodcons_initialize(&win->queue); 221 218 transform_identity(&win->transform); … … 235 232 static void window_destroy(window_t *win) 236 233 { 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 234 if (win) { 244 235 if (win->surface) { 245 236 surface_destroy(win->surface); … … 319 310 } 320 311 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 369 312 static void comp_damage(sysarg_t x_dmg_glob, sysarg_t y_dmg_glob, 370 313 sysarg_t w_dmg_glob, sysarg_t h_dmg_glob) … … 752 695 } 753 696 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 be758 * 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 765 697 /* Calculate damage. */ 766 698 sysarg_t x = 0; … … 774 706 } 775 707 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 776 716 comp_damage(x, y, width, height); 777 717 … … 873 813 874 814 if (win) { 875 atomic_inc(&win->ref_cnt);876 815 async_answer_0(iid, EOK); 877 816 } else { … … 886 825 887 826 if (!IPC_GET_IMETHOD(call)) { 888 async_answer_0(callid, EOK); 889 atomic_dec(&win->ref_cnt); 890 window_destroy(win); 827 async_answer_0(callid, EINVAL); 891 828 return; 892 829 } … … 905 842 906 843 if (!IPC_GET_IMETHOD(call)) { 907 comp_window_close(win, callid, &call); 908 atomic_dec(&win->ref_cnt); 909 window_destroy(win); 844 async_answer_0(callid, EINVAL); 910 845 return; 911 846 } … … 922 857 break; 923 858 case WINDOW_CLOSE: 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); 859 comp_window_close(win, callid, &call); 927 860 break; 928 861 case WINDOW_CLOSE_REQUEST: … … 978 911 async_answer_0(iid, EOK); 979 912 980 comp_restrict_pointers();981 913 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); 982 914 } … … 1024 956 fibril_mutex_unlock(&viewport_list_mtx); 1025 957 async_answer_0(iid, EOK); 1026 1027 comp_restrict_pointers();1028 comp_damage(0, 0, UINT32_MAX, UINT32_MAX);1029 958 } 1030 959 } … … 1462 1391 surface_get_resolution(pointer->cursor.states[pointer->state], 1463 1392 &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 }1476 1393 pointer->pos.x += dx; 1477 1394 pointer->pos.y += dy; … … 1993 1910 fibril_mutex_unlock(&viewport_list_mtx); 1994 1911 1995 comp_restrict_pointers();1996 1912 comp_damage(x, y, width, height); 1997 1913 } else { … … 2046 1962 } 2047 1963 list_prepend(&blue_win->link, &window_list); 2048 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 2049 1969 window_t *nameic_win = window_create(0, 0); 2050 1970 nameic_win->surface = decode_tga((void *) nameic_tga, nameic_tga_size, 0); … … 2172 2092 /* Establish input bidirectional connection. */ 2173 2093 rc = input_connect(input_svc); 2174 if (rc != EOK) 2094 if (rc != EOK) { 2095 printf("%s: Failed to connect to input service.\n", NAME); 2175 2096 return rc; 2097 } 2176 2098 2177 2099 /* Create viewports and connect them to visualizers. */ … … 2179 2101 rc = loc_category_get_id("visualizer", &cat_id, IPC_FLAG_BLOCKING); 2180 2102 if (rc != EOK) { 2103 printf("%s: Failed to get visualizer category.\n", NAME); 2181 2104 input_disconnect(); 2182 2105 return -1; … … 2187 2110 rc = loc_category_get_svcs(cat_id, &svcs, &svcs_cnt); 2188 2111 if (rc != EOK || svcs_cnt == 0) { 2112 printf("%s: Failed to get visualizer category services.\n", NAME); 2189 2113 input_disconnect(); 2190 2114 return -1; … … 2203 2127 2204 2128 if (list_empty(&viewport_list)) { 2129 printf("%s: Failed to get view ports.\n", NAME); 2205 2130 input_disconnect(); 2206 2131 return -1; 2207 2132 } 2208 2209 comp_restrict_pointers(); 2133 2210 2134 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); 2211 2135
Note:
See TracChangeset
for help on using the changeset viewer.