Changes in uspace/srv/hid/compositor/compositor.c [5a6cc679:a35b458] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/compositor/compositor.c
r5a6cc679 ra35b458 177 177 if (!p) 178 178 return NULL; 179 179 180 180 link_initialize(&p->link); 181 181 p->pos.x = coord_origin; … … 189 189 p->state = 0; 190 190 cursor_init(&p->cursor, CURSOR_DECODER_EMBEDDED, NULL); 191 191 192 192 /* Ghost window for transformation animation. */ 193 193 transform_identity(&p->ghost.transform); … … 202 202 p->accum_ghost.x = 0; 203 203 p->accum_ghost.y = 0; 204 204 205 205 return p; 206 206 } … … 219 219 if (!win) 220 220 return NULL; 221 221 222 222 link_initialize(&win->link); 223 223 atomic_set(&win->ref_cnt, 0); … … 232 232 win->opacity = 255; 233 233 win->surface = NULL; 234 234 235 235 return win; 236 236 } … … 244 244 free(event); 245 245 } 246 246 247 247 if (win->surface) 248 248 surface_destroy(win->surface); 249 249 250 250 free(win); 251 251 } … … 259 259 transform_invert(&win_trans); 260 260 transform_apply_affine(&win_trans, &x, &y); 261 261 262 262 /* 263 263 * Since client coordinate origin is (0, 0), it is necessary to check … … 268 268 if ((x < 0) || (y < 0)) 269 269 return false; 270 270 271 271 (*x_out) = (sysarg_t) (x + 0.5); 272 272 (*y_out) = (sysarg_t) (y + 0.5); 273 273 274 274 if (((*x_out) >= x_lim) || ((*y_out) >= y_lim)) 275 275 return false; 276 276 277 277 return true; 278 278 } … … 284 284 double y = y_in; 285 285 transform_apply_affine(&win_trans, &x, &y); 286 286 287 287 /* 288 288 * It is assumed that compositor coordinate origin is chosen in such way, … … 300 300 sysarg_t x[4]; 301 301 sysarg_t y[4]; 302 302 303 303 comp_coord_from_client(x_in, y_in, win_trans, &x[0], &y[0]); 304 304 comp_coord_from_client(x_in + w_in - 1, y_in, win_trans, &x[1], &y[1]); 305 305 comp_coord_from_client(x_in + w_in - 1, y_in + h_in - 1, win_trans, &x[2], &y[2]); 306 306 comp_coord_from_client(x_in, y_in + h_in - 1, win_trans, &x[3], &y[3]); 307 307 308 308 (*x_out) = x[0]; 309 309 (*y_out) = y[0]; 310 310 (*w_out) = x[0]; 311 311 (*h_out) = y[0]; 312 312 313 313 for (unsigned int i = 1; i < 4; ++i) { 314 314 (*x_out) = (x[i] < (*x_out)) ? x[i] : (*x_out); … … 317 317 (*h_out) = (y[i] > (*h_out)) ? y[i] : (*h_out); 318 318 } 319 319 320 320 (*w_out) = (*w_out) - (*x_out) + 1; 321 321 (*h_out) = (*h_out) - (*y_out) + 1; … … 331 331 { 332 332 fibril_mutex_lock(&viewport_list_mtx); 333 333 334 334 sysarg_t x_res = coord_origin; 335 335 sysarg_t y_res = coord_origin; 336 336 sysarg_t w_res = 0; 337 337 sysarg_t h_res = 0; 338 338 339 339 if (!list_empty(&viewport_list)) { 340 340 viewport_t *vp = (viewport_t *) list_first(&viewport_list); … … 343 343 surface_get_resolution(vp->surface, &w_res, &h_res); 344 344 } 345 345 346 346 list_foreach(viewport_list, link, viewport_t, vp) { 347 347 sysarg_t w_vp, h_vp; … … 351 351 &x_res, &y_res, &w_res, &h_res); 352 352 } 353 353 354 354 viewport_bound_rect.x = x_res; 355 355 viewport_bound_rect.y = y_res; 356 356 viewport_bound_rect.w = w_res; 357 357 viewport_bound_rect.h = h_res; 358 358 359 359 fibril_mutex_unlock(&viewport_list_mtx); 360 360 } … … 363 363 { 364 364 comp_update_viewport_bound_rect(); 365 365 366 366 fibril_mutex_lock(&pointer_list_mtx); 367 367 368 368 list_foreach(pointer_list, link, pointer_t, ptr) { 369 369 ptr->pos.x = ptr->pos.x > viewport_bound_rect.x ? ptr->pos.x : viewport_bound_rect.x; … … 374 374 ptr->pos.y : viewport_bound_rect.y + viewport_bound_rect.h; 375 375 } 376 376 377 377 fibril_mutex_unlock(&pointer_list_mtx); 378 378 } … … 585 585 } 586 586 } 587 587 588 588 fibril_mutex_unlock(&viewport_list_mtx); 589 589 } … … 601 601 return; 602 602 } 603 603 604 604 errno_t rc = async_data_read_finalize(callid, event, len); 605 605 if (rc != EOK) { … … 608 608 return; 609 609 } 610 610 611 611 async_answer_0(iid, EOK); 612 612 free(event); … … 638 638 sysarg_t pos_id = IPC_GET_ARG1(*icall); 639 639 sysarg_t grab_flags = IPC_GET_ARG2(*icall); 640 640 641 641 /* 642 642 * Filter out resize grab flags if the window … … 669 669 transform_identity(&translate); 670 670 transform_translate(&translate, win->dx, win->dy); 671 671 672 672 transform_t scale; 673 673 transform_identity(&scale); 674 674 if ((win->fx != 1) || (win->fy != 1)) 675 675 transform_scale(&scale, win->fx, win->fy); 676 676 677 677 transform_t rotate; 678 678 transform_identity(&rotate); 679 679 if (win->angle != 0) 680 680 transform_rotate(&rotate, win->angle); 681 681 682 682 transform_t transform; 683 683 transform_t temp; … … 689 689 temp = transform; 690 690 transform_product(&transform, &temp, &scale); 691 691 692 692 win->transform = transform; 693 693 } … … 698 698 size_t size; 699 699 unsigned int flags; 700 700 701 701 /* Start sharing resized window with client. */ 702 702 if (!async_share_out_receive(&callid, &size, &flags)) { … … 704 704 return; 705 705 } 706 706 707 707 void *new_cell_storage; 708 708 errno_t rc = async_share_out_finalize(callid, &new_cell_storage); … … 711 711 return; 712 712 } 713 713 714 714 /* Create new surface for the resized window. */ 715 715 surface_t *new_surface = surface_create(IPC_GET_ARG3(*icall), … … 720 720 return; 721 721 } 722 722 723 723 sysarg_t offset_x = IPC_GET_ARG1(*icall); 724 724 sysarg_t offset_y = IPC_GET_ARG2(*icall); 725 725 window_placement_flags_t placement_flags = 726 726 (window_placement_flags_t) IPC_GET_ARG5(*icall); 727 727 728 728 comp_update_viewport_bound_rect(); 729 729 730 730 /* Switch new surface with old surface and calculate damage. */ 731 731 fibril_mutex_lock(&window_list_mtx); 732 732 733 733 sysarg_t old_width = 0; 734 734 sysarg_t old_height = 0; 735 735 736 736 if (win->surface) { 737 737 surface_get_resolution(win->surface, &old_width, &old_height); 738 738 surface_destroy(win->surface); 739 739 } 740 740 741 741 win->surface = new_surface; 742 742 743 743 sysarg_t new_width = 0; 744 744 sysarg_t new_height = 0; 745 745 surface_get_resolution(win->surface, &new_width, &new_height); 746 746 747 747 if (placement_flags & WINDOW_PLACEMENT_CENTER_X) 748 748 win->dx = viewport_bound_rect.x + viewport_bound_rect.w / 2 - 749 749 new_width / 2; 750 750 751 751 if (placement_flags & WINDOW_PLACEMENT_CENTER_Y) 752 752 win->dy = viewport_bound_rect.y + viewport_bound_rect.h / 2 - 753 753 new_height / 2; 754 754 755 755 if (placement_flags & WINDOW_PLACEMENT_LEFT) 756 756 win->dx = viewport_bound_rect.x; 757 757 758 758 if (placement_flags & WINDOW_PLACEMENT_TOP) 759 759 win->dy = viewport_bound_rect.y; 760 760 761 761 if (placement_flags & WINDOW_PLACEMENT_RIGHT) 762 762 win->dx = viewport_bound_rect.x + viewport_bound_rect.w - 763 763 new_width; 764 764 765 765 if (placement_flags & WINDOW_PLACEMENT_BOTTOM) 766 766 win->dy = viewport_bound_rect.y + viewport_bound_rect.h - 767 767 new_height; 768 768 769 769 if (placement_flags & WINDOW_PLACEMENT_ABSOLUTE_X) 770 770 win->dx = coord_origin + offset_x; 771 771 772 772 if (placement_flags & WINDOW_PLACEMENT_ABSOLUTE_Y) 773 773 win->dy = coord_origin + offset_y; 774 774 775 775 /* Transform the window and calculate damage. */ 776 776 sysarg_t x1; … … 778 778 sysarg_t width1; 779 779 sysarg_t height1; 780 780 781 781 comp_coord_bounding_rect(0, 0, old_width, old_height, win->transform, 782 782 &x1, &y1, &width1, &height1); 783 783 784 784 comp_recalc_transform(win); 785 785 786 786 sysarg_t x2; 787 787 sysarg_t y2; 788 788 sysarg_t width2; 789 789 sysarg_t height2; 790 790 791 791 comp_coord_bounding_rect(0, 0, new_width, new_height, win->transform, 792 792 &x2, &y2, &width2, &height2); 793 793 794 794 sysarg_t x; 795 795 sysarg_t y; 796 796 sysarg_t width; 797 797 sysarg_t height; 798 798 799 799 rectangle_union(x1, y1, width1, height1, x2, y2, width2, height2, 800 800 &x, &y, &width, &height); 801 801 802 802 fibril_mutex_unlock(&window_list_mtx); 803 803 804 804 comp_damage(x, y, width, height); 805 805 806 806 async_answer_0(iid, EOK); 807 807 } … … 810 810 { 811 811 fibril_mutex_lock(&window_list_mtx); 812 812 813 813 list_foreach(window_list, link, window_t, window) { 814 814 if (window == target) { … … 818 818 } 819 819 } 820 820 821 821 fibril_mutex_unlock(&window_list_mtx); 822 822 free(event); … … 826 826 { 827 827 fibril_mutex_lock(&window_list_mtx); 828 828 829 829 window_t *win = (window_t *) list_first(&window_list); 830 830 if (win) … … 832 832 else 833 833 free(event); 834 834 835 835 fibril_mutex_unlock(&window_list_mtx); 836 836 } … … 914 914 return; 915 915 } 916 916 917 917 win->flags = IPC_GET_ARG1(call); 918 918 … … 950 950 event_unfocus->type = ET_WINDOW_UNFOCUS; 951 951 } 952 952 953 953 async_answer_2(callid, EOK, win->in_dsid, win->out_dsid); 954 954 fibril_mutex_unlock(&window_list_mtx); 955 955 956 956 if (event_unfocus && win_unfocus) { 957 957 comp_post_event_win(event_unfocus, win_unfocus); … … 1102 1102 loc_service_unregister(winreg_id); 1103 1103 input_disconnect(); 1104 1104 1105 1105 /* Close all clients and their windows. */ 1106 1106 fibril_mutex_lock(&window_list_mtx); … … 1114 1114 } 1115 1115 fibril_mutex_unlock(&window_list_mtx); 1116 1116 1117 1117 async_answer_0(iid, EOK); 1118 1118 1119 1119 /* All fibrils of the compositor will terminate soon. */ 1120 1120 } … … 1125 1125 /* Release viewport resources. */ 1126 1126 fibril_mutex_lock(&viewport_list_mtx); 1127 1127 1128 1128 list_remove(&vp->link); 1129 1129 viewport_destroy(vp); 1130 1130 1131 1131 fibril_mutex_unlock(&viewport_list_mtx); 1132 1132 1133 1133 async_answer_0(iid, EOK); 1134 1134 1135 1135 comp_restrict_pointers(); 1136 1136 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); … … 1187 1187 1188 1188 async_exch_t *exch = async_exchange_begin(sess); 1189 1189 1190 1190 port_id_t port; 1191 1191 rc = async_create_callback_port(exch, INTERFACE_VISUALIZER_CB, 0, 0, 1192 1192 vsl_notifications, NULL, &port); 1193 1193 1194 1194 async_exchange_end(exch); 1195 1195 … … 1265 1265 if (claimed) 1266 1266 visualizer_yield(vp->sess); 1267 1267 1268 1268 if (vp->sess != NULL) 1269 1269 async_hangup(vp->sess); 1270 1270 1271 1271 free(vp); 1272 1272 free(vsl_name); … … 1295 1295 double cx = 0; 1296 1296 double cy = 0; 1297 1297 1298 1298 if (pointer->grab_flags & GF_MOVE_X) 1299 1299 cx = 1; 1300 1300 1301 1301 if (pointer->grab_flags & GF_MOVE_Y) 1302 1302 cy = 1; 1303 1303 1304 1304 if (((scale) || (resize)) && (win->angle != 0)) { 1305 1305 transform_t rotate; 1306 1306 transform_identity(&rotate); 1307 1307 1308 1308 transform_rotate(&rotate, win->angle); 1309 1309 transform_apply_linear(&rotate, &cx, &cy); 1310 1310 } 1311 1311 1312 1312 cx = (cx < 0) ? (-1 * cx) : cx; 1313 1313 cy = (cy < 0) ? (-1 * cy) : cy; 1314 1314 1315 1315 win->dx += (cx * dx); 1316 1316 win->dy += (cy * dy); … … 1468 1468 rect3->w = w_u - w_i - x_i + x_u + 1; 1469 1469 rect3->h = h_u; 1470 1470 1471 1471 rect4->x = x_u; 1472 1472 rect4->y = y_i + h_i - 1; … … 1481 1481 { 1482 1482 /* XXX TODO Use absolute coordinates directly */ 1483 1483 1484 1484 pointer_t *pointer = input_pointer(input); 1485 1485 1486 1486 sysarg_t width, height; 1487 1487 1488 1488 fibril_mutex_lock(&viewport_list_mtx); 1489 1489 if (list_empty(&viewport_list)) { … … 1501 1501 pos_in_viewport.x = x * width / max_x; 1502 1502 pos_in_viewport.y = y * height / max_y; 1503 1503 1504 1504 /* Calculate offset from pointer */ 1505 1505 fibril_mutex_lock(&pointer_list_mtx); … … 1508 1508 delta.y = (vp_pos.y + pos_in_viewport.y) - pointer->pos.y; 1509 1509 fibril_mutex_unlock(&pointer_list_mtx); 1510 1510 1511 1511 return comp_mouse_move(input, delta.x, delta.y); 1512 1512 } … … 1515 1515 { 1516 1516 pointer_t *pointer = input_pointer(input); 1517 1517 1518 1518 comp_update_viewport_bound_rect(); 1519 1519 1520 1520 /* Update pointer position. */ 1521 1521 fibril_mutex_lock(&pointer_list_mtx); 1522 1522 1523 1523 desktop_point_t old_pos = pointer->pos; 1524 1524 1525 1525 sysarg_t cursor_width; 1526 1526 sysarg_t cursor_height; 1527 1527 surface_get_resolution(pointer->cursor.states[pointer->state], 1528 1528 &cursor_width, &cursor_height); 1529 1529 1530 1530 if (pointer->pos.x + dx < viewport_bound_rect.x) 1531 1531 dx = -1 * (pointer->pos.x - viewport_bound_rect.x); 1532 1532 1533 1533 if (pointer->pos.y + dy < viewport_bound_rect.y) 1534 1534 dy = -1 * (pointer->pos.y - viewport_bound_rect.y); 1535 1535 1536 1536 if (pointer->pos.x + dx > viewport_bound_rect.x + viewport_bound_rect.w) 1537 1537 dx = (viewport_bound_rect.x + viewport_bound_rect.w - pointer->pos.x); 1538 1538 1539 1539 if (pointer->pos.y + dy > viewport_bound_rect.y + viewport_bound_rect.h) 1540 1540 dy = (viewport_bound_rect.y + viewport_bound_rect.h - pointer->pos.y); 1541 1541 1542 1542 pointer->pos.x += dx; 1543 1543 pointer->pos.y += dy; … … 1545 1545 comp_damage(old_pos.x, old_pos.y, cursor_width, cursor_height); 1546 1546 comp_damage(old_pos.x + dx, old_pos.y + dy, cursor_width, cursor_height); 1547 1547 1548 1548 fibril_mutex_lock(&window_list_mtx); 1549 1549 fibril_mutex_lock(&pointer_list_mtx); … … 1663 1663 sysarg_t dmg_width = 0; 1664 1664 sysarg_t dmg_height = 0; 1665 1665 1666 1666 #if ANIMATE_WINDOW_TRANSFORMS == 0 1667 1667 desktop_rect_t dmg_rect1, dmg_rect2, dmg_rect3, dmg_rect4; … … 1738 1738 link_initialize(&event_top->link); 1739 1739 event_top->type = ET_WINDOW_RESIZE; 1740 1740 1741 1741 event_top->data.resize.offset_x = 0; 1742 1742 event_top->data.resize.offset_y = 0; 1743 1743 1744 1744 int dx = (int) (((double) width) * (scale_back_x - 1.0)); 1745 1745 int dy = (int) (((double) height) * (scale_back_y - 1.0)); 1746 1746 1747 1747 if (pointer->grab_flags & GF_RESIZE_X) 1748 1748 event_top->data.resize.width = … … 1750 1750 else 1751 1751 event_top->data.resize.width = width; 1752 1752 1753 1753 if (pointer->grab_flags & GF_RESIZE_Y) 1754 1754 event_top->data.resize.height = … … 1756 1756 else 1757 1757 event_top->data.resize.height = height; 1758 1758 1759 1759 event_top->data.resize.placement_flags = 1760 1760 WINDOW_PLACEMENT_ANY; … … 1764 1764 1765 1765 } else if (within_client && (pointer->grab_flags == GF_EMPTY) && (top == win)) { 1766 1766 1767 1767 /* Notify top-level window about mouse release. */ 1768 1768 event_top = (window_event_t *) malloc(sizeof(window_event_t)); … … 1777 1777 } 1778 1778 pointer->grab_flags = GF_EMPTY; 1779 1779 1780 1780 } else { 1781 1781 pointer->grab_flags = GF_EMPTY; … … 1813 1813 active = true; 1814 1814 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); 1815 1815 1816 1816 return EOK; 1817 1817 } … … 1910 1910 return ENOMEM; 1911 1911 } 1912 1912 1913 1913 sysarg_t width, height; 1914 1914 surface_get_resolution(win->surface, &width, &height); 1915 1915 1916 1916 link_initialize(&event->link); 1917 1917 event->type = ET_WINDOW_RESIZE; 1918 1918 1919 1919 event->data.resize.offset_x = 0; 1920 1920 event->data.resize.offset_y = 0; 1921 1921 1922 1922 switch (key) { 1923 1923 case KC_T: … … 1942 1942 break; 1943 1943 } 1944 1944 1945 1945 event->data.resize.placement_flags = WINDOW_PLACEMENT_ANY; 1946 1946 1947 1947 fibril_mutex_unlock(&window_list_mtx); 1948 1948 comp_post_event_top(event); … … 2075 2075 break; 2076 2076 } 2077 2077 2078 2078 sysarg_t x = vp->pos.x; 2079 2079 sysarg_t y = vp->pos.y; … … 2196 2196 { 2197 2197 fibril_mutex_lock(&discovery_mtx); 2198 2198 2199 2199 /* Create viewports and connect them to visualizers. */ 2200 2200 category_id_t cat_id; … … 2202 2202 if (rc != EOK) 2203 2203 goto ret; 2204 2204 2205 2205 service_id_t *svcs; 2206 2206 size_t svcs_cnt = 0; … … 2208 2208 if (rc != EOK) 2209 2209 goto ret; 2210 2210 2211 2211 fibril_mutex_lock(&viewport_list_mtx); 2212 2212 for (size_t i = 0; i < svcs_cnt; ++i) { … … 2218 2218 } 2219 2219 } 2220 2220 2221 2221 if (exists) 2222 2222 continue; 2223 2223 2224 2224 viewport_t *vp = viewport_create(svcs[i]); 2225 2225 if (vp != NULL) … … 2227 2227 } 2228 2228 fibril_mutex_unlock(&viewport_list_mtx); 2229 2229 2230 2230 if (!list_empty(&viewport_list)) 2231 2231 input_activate(input); 2232 2232 2233 2233 ret: 2234 2234 fibril_mutex_unlock(&discovery_mtx); … … 2244 2244 /* Coordinates of the central pixel. */ 2245 2245 coord_origin = UINT32_MAX / 4; 2246 2246 2247 2247 /* Color of the viewport background. Must be opaque. */ 2248 2248 bg_color = PIXEL(255, 69, 51, 103); 2249 2249 2250 2250 /* Register compositor server. */ 2251 2251 async_set_fallback_port_handler(client_connection, NULL); 2252 2252 2253 2253 errno_t rc = loc_server_register(NAME); 2254 2254 if (rc != EOK) { … … 2256 2256 return -1; 2257 2257 } 2258 2258 2259 2259 server_name = name; 2260 2260 2261 2261 char svc[LOC_NAME_MAXLEN + 1]; 2262 2262 snprintf(svc, LOC_NAME_MAXLEN, "%s/%s", NAMESPACE, server_name); 2263 2263 2264 2264 service_id_t service_id; 2265 2265 rc = loc_service_register(svc, &service_id); … … 2268 2268 return rc; 2269 2269 } 2270 2270 2271 2271 /* Prepare window registrator (entrypoint for clients). */ 2272 2272 char winreg[LOC_NAME_MAXLEN + 1]; … … 2276 2276 return -1; 2277 2277 } 2278 2278 2279 2279 /* Establish input bidirectional connection. */ 2280 2280 rc = input_connect(input_svc); … … 2283 2283 return rc; 2284 2284 } 2285 2285 2286 2286 rc = loc_register_cat_change_cb(category_change_cb); 2287 2287 if (rc != EOK) { … … 2290 2290 return rc; 2291 2291 } 2292 2292 2293 2293 discover_viewports(); 2294 2294 2295 2295 comp_restrict_pointers(); 2296 2296 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); 2297 2297 2298 2298 return EOK; 2299 2299 } … … 2310 2310 return 1; 2311 2311 } 2312 2312 2313 2313 printf("%s: HelenOS Compositor server\n", NAME); 2314 2314 2315 2315 errno_t rc = compositor_srv_init(argv[1], argv[2]); 2316 2316 if (rc != EOK) 2317 2317 return rc; 2318 2318 2319 2319 printf("%s: Accepting connections\n", NAME); 2320 2320 task_retval(0); 2321 2321 async_manager(); 2322 2322 2323 2323 /* Never reached */ 2324 2324 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.