Changeset 3b98311 in mainline for uspace/srv/hid/compositor/compositor.c
- Timestamp:
- 2013-04-21T19:28:24Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9e7898e
- Parents:
- 21eeb653
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/compositor/compositor.c
r21eeb653 r3b98311 139 139 } viewport_t; 140 140 141 static desktop_rect_t viewport_bound_rect; 141 142 static FIBRIL_MUTEX_INITIALIZE(viewport_list_mtx); 142 143 static LIST_INITIALIZE(viewport_list); … … 318 319 } 319 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 320 369 static void comp_damage(sysarg_t x_dmg_glob, sysarg_t y_dmg_glob, 321 370 sysarg_t w_dmg_glob, sysarg_t h_dmg_glob) … … 929 978 async_answer_0(iid, EOK); 930 979 980 comp_restrict_pointers(); 931 981 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); 932 982 } … … 974 1024 fibril_mutex_unlock(&viewport_list_mtx); 975 1025 async_answer_0(iid, EOK); 1026 1027 comp_restrict_pointers(); 1028 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); 976 1029 } 977 1030 } … … 1409 1462 surface_get_resolution(pointer->cursor.states[pointer->state], 1410 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 } 1411 1476 pointer->pos.x += dx; 1412 1477 pointer->pos.y += dy; … … 1928 1993 fibril_mutex_unlock(&viewport_list_mtx); 1929 1994 1995 comp_restrict_pointers(); 1930 1996 comp_damage(x, y, width, height); 1931 1997 } else { … … 2140 2206 return -1; 2141 2207 } 2142 2208 2209 comp_restrict_pointers(); 2143 2210 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); 2144 2211
Note:
See TracChangeset
for help on using the changeset viewer.