Changeset 290a0f0 in mainline for uspace/srv/hid/compositor/compositor.c
- Timestamp:
- 2012-11-25T19:34:10Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fa98b26a
- Parents:
- c4ebe02
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/compositor/compositor.c
rc4ebe02 r290a0f0 573 573 pointer_t *pointer = list_get_instance(link, pointer_t, link); 574 574 if (pointer->id == pos_id) { 575 pointer->grab_flags = grab_flags;575 pointer->grab_flags = pointer->pressed ? grab_flags : GF_EMPTY; 576 576 // TODO change pointer->state according to grab_flags 577 577 break; … … 646 646 } 647 647 648 static void comp_post_event_win(window_event_t *event, window_t *target) 649 { 650 fibril_mutex_lock(&window_list_mtx); 651 window_t *window = NULL; 652 list_foreach(window_list, link) { 653 window = list_get_instance(link, window_t, link); 654 if (window == target) { 655 prodcons_produce(&window->queue, &event->link); 656 } 657 } 658 if (!window) { 659 free(event); 660 } 661 fibril_mutex_unlock(&window_list_mtx); 662 } 663 664 static void comp_post_event_top(window_event_t *event) 665 { 666 fibril_mutex_lock(&window_list_mtx); 667 window_t *win = (window_t *) list_first(&window_list); 668 if (win) { 669 prodcons_produce(&win->queue, &event->link); 670 } else { 671 free(event); 672 } 673 fibril_mutex_unlock(&window_list_mtx); 674 } 675 648 676 static void comp_window_close(window_t *win, ipc_callid_t iid, ipc_call_t *icall) 649 677 { … … 651 679 fibril_mutex_lock(&window_list_mtx); 652 680 list_remove(&win->link); 681 window_t *win_focus = (window_t *) list_first(&window_list); 682 window_event_t *event_focus = (window_event_t *) malloc(sizeof(window_event_t)); 683 if (event_focus) { 684 link_initialize(&event_focus->link); 685 event_focus->type = ET_WINDOW_FOCUS; 686 } 653 687 fibril_mutex_unlock(&window_list_mtx); 688 689 if (event_focus && win_focus) { 690 comp_post_event_win(event_focus, win_focus); 691 } 654 692 655 693 /* Calculate damage. */ … … 735 773 } 736 774 775 window_t *win_unfocus = (window_t *) list_first(&window_list); 737 776 list_prepend(&win->link, &window_list); 777 778 window_event_t *event_unfocus = (window_event_t *) malloc(sizeof(window_event_t)); 779 if (event_unfocus) { 780 link_initialize(&event_unfocus->link); 781 event_unfocus->type = ET_WINDOW_UNFOCUS; 782 } 738 783 739 784 async_answer_2(callid, EOK, win->in_dsid, win->out_dsid); 740 785 fibril_mutex_unlock(&window_list_mtx); 786 787 if (event_unfocus && win_unfocus) { 788 comp_post_event_win(event_unfocus, win_unfocus); 789 } 790 741 791 return; 742 792 } else { … … 1058 1108 } 1059 1109 1060 static void comp_post_event(window_event_t *event)1061 {1062 fibril_mutex_lock(&window_list_mtx);1063 window_t *win = (window_t *) list_first(&window_list);1064 if (win) {1065 prodcons_produce(&win->queue, &event->link);1066 } else {1067 free(event);1068 }1069 fibril_mutex_unlock(&window_list_mtx);1070 }1071 1072 1110 static void comp_recalc_transform(window_t *win) 1073 1111 { … … 1102 1140 { 1103 1141 /* window_list_mtx locked by caller */ 1142 /* pointer_list_mtx locked by caller */ 1104 1143 1105 1144 int dx = pointer->accum.x; … … 1181 1220 desktop_rect_t *rect1, desktop_rect_t *rect2, desktop_rect_t *rect3, desktop_rect_t *rect4) 1182 1221 { 1222 /* window_list_mtx locked by caller */ 1223 /* pointer_list_mtx locked by caller */ 1224 1183 1225 int dx = pointer->accum_ghost.x; 1184 1226 int dy = pointer->accum_ghost.y; … … 1336 1378 1337 1379 fibril_mutex_lock(&window_list_mtx); 1380 fibril_mutex_lock(&pointer_list_mtx); 1338 1381 window_t *top = (window_t *) list_first(&window_list); 1339 1382 if (top && top->surface) { … … 1347 1390 within_client = comp_coord_to_client(pointer->pos.x, pointer->pos.y, 1348 1391 top->transform, width, height, &point_x, &point_y); 1349 fibril_mutex_unlock(&window_list_mtx); 1350 1392 1393 window_event_t *event = NULL; 1351 1394 if (within_client) { 1352 window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t));1395 event = (window_event_t *) malloc(sizeof(window_event_t)); 1353 1396 if (event) { 1354 1397 link_initialize(&event->link); … … 1359 1402 event->data.pos.hpos = point_x; 1360 1403 event->data.pos.vpos = point_y; 1361 comp_post_event(event);1362 1404 } 1363 1405 } 1406 1407 fibril_mutex_unlock(&pointer_list_mtx); 1408 fibril_mutex_unlock(&window_list_mtx); 1409 1410 if (event) { 1411 comp_post_event_top(event); 1412 } 1413 1364 1414 } else { 1365 1415 /* Pointer is grabbed by top-level window action. */ … … 1385 1435 comp_window_animate(pointer, top, &x, &y, &width, &height); 1386 1436 #endif 1437 fibril_mutex_unlock(&pointer_list_mtx); 1387 1438 fibril_mutex_unlock(&window_list_mtx); 1388 1439 #if ANIMATE_WINDOW_TRANSFORMS == 0 … … 1397 1448 } 1398 1449 } else { 1450 fibril_mutex_unlock(&pointer_list_mtx); 1399 1451 fibril_mutex_unlock(&window_list_mtx); 1400 1452 } … … 1408 1460 1409 1461 fibril_mutex_lock(&window_list_mtx); 1462 fibril_mutex_lock(&pointer_list_mtx); 1410 1463 window_t *win = NULL; 1411 1464 sysarg_t point_x = 0; … … 1430 1483 window_t *top = (window_t *) list_first(&window_list); 1431 1484 if (!win || !top) { 1485 fibril_mutex_unlock(&pointer_list_mtx); 1432 1486 fibril_mutex_unlock(&window_list_mtx); 1433 1487 return EOK; 1434 1488 } 1435 1489 1436 window_event_t *event = NULL; 1490 window_event_t *event_top = NULL; 1491 window_event_t *event_unfocus = NULL; 1492 window_t *win_unfocus = NULL; 1437 1493 sysarg_t dmg_x, dmg_y; 1438 1494 sysarg_t dmg_width = 0; … … 1450 1506 /* Bring the window to the foreground. */ 1451 1507 if ((win != top) && within_client) { 1508 win_unfocus = (window_t *) list_first(&window_list); 1452 1509 list_remove(&win->link); 1453 1510 list_prepend(&win->link, &window_list); 1511 event_unfocus = (window_event_t *) malloc(sizeof(window_event_t)); 1512 if (event_unfocus) { 1513 link_initialize(&event_unfocus->link); 1514 event_unfocus->type = ET_WINDOW_UNFOCUS; 1515 } 1454 1516 comp_coord_bounding_rect(0, 0, width, height, win->transform, 1455 1517 &dmg_x, &dmg_y, &dmg_width, &dmg_height); … … 1458 1520 /* Notify top-level window about mouse press. */ 1459 1521 if (within_client) { 1460 event = (window_event_t *) malloc(sizeof(window_event_t));1461 if (event ) {1462 link_initialize(&event ->link);1463 event ->type = ET_POSITION_EVENT;1464 event ->data.pos.pos_id = pointer->id;1465 event ->data.pos.type = POS_PRESS;1466 event ->data.pos.btn_num = bnum;1467 event ->data.pos.hpos = point_x;1468 event ->data.pos.vpos = point_y;1522 event_top = (window_event_t *) malloc(sizeof(window_event_t)); 1523 if (event_top) { 1524 link_initialize(&event_top->link); 1525 event_top->type = ET_POSITION_EVENT; 1526 event_top->data.pos.pos_id = pointer->id; 1527 event_top->data.pos.type = POS_PRESS; 1528 event_top->data.pos.btn_num = bnum; 1529 event_top->data.pos.hpos = point_x; 1530 event_top->data.pos.vpos = point_y; 1469 1531 } 1470 1532 pointer->grab_flags = GF_EMPTY; … … 1501 1563 1502 1564 /* Commit proper resize action. */ 1503 event = (window_event_t *) malloc(sizeof(window_event_t));1504 if (event ) {1505 link_initialize(&event ->link);1506 event ->type = ET_WINDOW_RESIZE;1565 event_top = (window_event_t *) malloc(sizeof(window_event_t)); 1566 if (event_top) { 1567 link_initialize(&event_top->link); 1568 event_top->type = ET_WINDOW_RESIZE; 1507 1569 1508 1570 int dx = (int) (((double) width) * (scale_back_x - 1.0)); … … 1510 1572 1511 1573 if (pointer->grab_flags & GF_RESIZE_X) { 1512 event ->data.rsz.width =1574 event_top->data.rsz.width = 1513 1575 ((((int) width) + dx) >= 0) ? (width + dx) : 0; 1514 1576 } else { 1515 event ->data.rsz.width = width;1577 event_top->data.rsz.width = width; 1516 1578 } 1517 1579 1518 1580 if (pointer->grab_flags & GF_RESIZE_Y) { 1519 event ->data.rsz.height =1581 event_top->data.rsz.height = 1520 1582 ((((int) height) + dy) >= 0) ? (height + dy) : 0; 1521 1583 } else { 1522 event ->data.rsz.height = height;1584 event_top->data.rsz.height = height; 1523 1585 } 1524 1586 } … … 1529 1591 1530 1592 /* Notify top-level window about mouse release. */ 1531 event = (window_event_t *) malloc(sizeof(window_event_t));1532 if (event ) {1533 link_initialize(&event ->link);1534 event ->type = ET_POSITION_EVENT;1535 event ->data.pos.pos_id = pointer->id;1536 event ->data.pos.type = POS_RELEASE;1537 event ->data.pos.btn_num = bnum;1538 event ->data.pos.hpos = point_x;1539 event ->data.pos.vpos = point_y;1593 event_top = (window_event_t *) malloc(sizeof(window_event_t)); 1594 if (event_top) { 1595 link_initialize(&event_top->link); 1596 event_top->type = ET_POSITION_EVENT; 1597 event_top->data.pos.pos_id = pointer->id; 1598 event_top->data.pos.type = POS_RELEASE; 1599 event_top->data.pos.btn_num = bnum; 1600 event_top->data.pos.hpos = point_x; 1601 event_top->data.pos.vpos = point_y; 1540 1602 } 1541 1603 pointer->grab_flags = GF_EMPTY; … … 1547 1609 } 1548 1610 1611 fibril_mutex_unlock(&pointer_list_mtx); 1549 1612 fibril_mutex_unlock(&window_list_mtx); 1550 1613 … … 1560 1623 } 1561 1624 1562 if (event) { 1563 comp_post_event(event); 1625 if (event_unfocus && win_unfocus) { 1626 comp_post_event_win(event_unfocus, win_unfocus); 1627 } 1628 1629 if (event_top) { 1630 comp_post_event_top(event_top); 1564 1631 } 1565 1632 … … 1685 1752 1686 1753 fibril_mutex_unlock(&window_list_mtx); 1687 comp_post_event (event);1754 comp_post_event_top(event); 1688 1755 } else { 1689 1756 fibril_mutex_unlock(&window_list_mtx); … … 1727 1794 event->type = ET_WINDOW_CLOSE; 1728 1795 1729 comp_post_event (event);1796 comp_post_event_top(event); 1730 1797 } else if (win_switch) { 1731 1798 fibril_mutex_lock(&window_list_mtx); … … 1735 1802 list_append(&win1->link, &window_list); 1736 1803 window_t *win2 = (window_t *) list_first(&window_list); 1804 1805 window_event_t *event1 = (window_event_t *) malloc(sizeof(window_event_t)); 1806 if (event1) { 1807 link_initialize(&event1->link); 1808 event1->type = ET_WINDOW_UNFOCUS; 1809 } 1810 1811 window_event_t *event2 = (window_event_t *) malloc(sizeof(window_event_t)); 1812 if (event2) { 1813 link_initialize(&event2->link); 1814 event2->type = ET_WINDOW_FOCUS; 1815 } 1737 1816 1738 1817 sysarg_t x1 = 0; … … 1763 1842 1764 1843 fibril_mutex_unlock(&window_list_mtx); 1844 1845 if (event1 && win1) { 1846 comp_post_event_win(event1, win1); 1847 } 1848 1849 if (event2 && win2) { 1850 comp_post_event_win(event2, win2); 1851 } 1852 1765 1853 comp_damage(x, y, width, height); 1766 1854 } else { … … 1875 1963 event->data.kbd.c = c; 1876 1964 1877 comp_post_event (event);1965 comp_post_event_top(event); 1878 1966 } 1879 1967 … … 1926 2014 static void input_disconnect(void) 1927 2015 { 1928 2016 pointer_t *pointer = input->user; 1929 2017 input_close(input); 1930 2018 pointer_destroy(pointer);
Note:
See TracChangeset
for help on using the changeset viewer.