OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/exo/wayland/server.h" | 5 #include "components/exo/wayland/server.h" |
6 | 6 |
7 #include <grp.h> | 7 #include <grp.h> |
8 #include <linux/input.h> | 8 #include <linux/input.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1452 GetUserDataAs<ShellSurface>(resource)->SetGeometry( | 1452 GetUserDataAs<ShellSurface>(resource)->SetGeometry( |
1453 gfx::Rect(x, y, width, height)); | 1453 gfx::Rect(x, y, width, height)); |
1454 } | 1454 } |
1455 | 1455 |
1456 void remote_surface_set_scale(wl_client* client, | 1456 void remote_surface_set_scale(wl_client* client, |
1457 wl_resource* resource, | 1457 wl_resource* resource, |
1458 wl_fixed_t scale) { | 1458 wl_fixed_t scale) { |
1459 GetUserDataAs<ShellSurface>(resource)->SetScale(wl_fixed_to_double(scale)); | 1459 GetUserDataAs<ShellSurface>(resource)->SetScale(wl_fixed_to_double(scale)); |
1460 } | 1460 } |
1461 | 1461 |
1462 void remote_surface_fullscreen(wl_client* client, wl_resource* resource) { | 1462 void remote_surface_set_rectangular_shadow(wl_client* client, |
1463 GetUserDataAs<ShellSurface>(resource)->SetFullscreen(true); | 1463 wl_resource* resource, |
| 1464 int32_t x, |
| 1465 int32_t y, |
| 1466 int32_t width, |
| 1467 int32_t height) { |
| 1468 GetUserDataAs<ShellSurface>(resource)->SetRectangularShadow( |
| 1469 gfx::Rect(x, y, width, height)); |
| 1470 } |
| 1471 |
| 1472 void remote_surface_set_rectangular_shadow_background_opacity( |
| 1473 wl_client* client, |
| 1474 wl_resource* resource, |
| 1475 wl_fixed_t opacity) { |
| 1476 GetUserDataAs<ShellSurface>(resource)->SetRectangularShadowBackgroundOpacity( |
| 1477 wl_fixed_to_double(opacity)); |
| 1478 } |
| 1479 |
| 1480 void remote_surface_set_title(wl_client* client, |
| 1481 wl_resource* resource, |
| 1482 const char* title) { |
| 1483 GetUserDataAs<ShellSurface>(resource)->SetTitle( |
| 1484 base::string16(base::UTF8ToUTF16(title))); |
| 1485 } |
| 1486 |
| 1487 void remote_surface_set_top_inset(wl_client* client, |
| 1488 wl_resource* resource, |
| 1489 int32_t height) { |
| 1490 GetUserDataAs<ShellSurface>(resource)->SetTopInset(height); |
| 1491 } |
| 1492 |
| 1493 void remote_surface_activate(wl_client* client, |
| 1494 wl_resource* resource, |
| 1495 uint32_t serial) { |
| 1496 GetUserDataAs<ShellSurface>(resource)->Activate(); |
1464 } | 1497 } |
1465 | 1498 |
1466 void remote_surface_maximize(wl_client* client, wl_resource* resource) { | 1499 void remote_surface_maximize(wl_client* client, wl_resource* resource) { |
1467 GetUserDataAs<ShellSurface>(resource)->Maximize(); | 1500 GetUserDataAs<ShellSurface>(resource)->Maximize(); |
1468 } | 1501 } |
1469 | 1502 |
1470 void remote_surface_minimize(wl_client* client, wl_resource* resource) { | 1503 void remote_surface_minimize(wl_client* client, wl_resource* resource) { |
1471 GetUserDataAs<ShellSurface>(resource)->Minimize(); | 1504 GetUserDataAs<ShellSurface>(resource)->Minimize(); |
1472 } | 1505 } |
1473 | 1506 |
1474 void remote_surface_restore(wl_client* client, wl_resource* resource) { | 1507 void remote_surface_restore(wl_client* client, wl_resource* resource) { |
1475 GetUserDataAs<ShellSurface>(resource)->Restore(); | 1508 GetUserDataAs<ShellSurface>(resource)->Restore(); |
1476 } | 1509 } |
1477 | 1510 |
1478 void remote_surface_pin(wl_client* client, wl_resource* resource) { | 1511 void remote_surface_fullscreen(wl_client* client, wl_resource* resource) { |
| 1512 GetUserDataAs<ShellSurface>(resource)->SetFullscreen(true); |
| 1513 } |
| 1514 |
| 1515 void remote_surface_unfullscreen(wl_client* client, wl_resource* resource) { |
| 1516 GetUserDataAs<ShellSurface>(resource)->SetFullscreen(false); |
| 1517 } |
| 1518 |
| 1519 void remote_surface_pin(wl_client* client, |
| 1520 wl_resource* resource, |
| 1521 int32_t trusted) { |
1479 GetUserDataAs<ShellSurface>(resource)->SetPinned(true); | 1522 GetUserDataAs<ShellSurface>(resource)->SetPinned(true); |
1480 } | 1523 } |
1481 | 1524 |
1482 void remote_surface_unpin(wl_client* client, wl_resource* resource) { | 1525 void remote_surface_unpin(wl_client* client, wl_resource* resource) { |
1483 GetUserDataAs<ShellSurface>(resource)->SetPinned(false); | 1526 GetUserDataAs<ShellSurface>(resource)->SetPinned(false); |
1484 } | 1527 } |
1485 | 1528 |
1486 void remote_surface_unfullscreen(wl_client* client, wl_resource* resource) { | |
1487 GetUserDataAs<ShellSurface>(resource)->SetFullscreen(false); | |
1488 } | |
1489 | |
1490 void remote_surface_set_rectangular_shadow(wl_client* client, | |
1491 wl_resource* resource, | |
1492 int32_t x, | |
1493 int32_t y, | |
1494 int32_t width, | |
1495 int32_t height) { | |
1496 GetUserDataAs<ShellSurface>(resource)->SetRectangularShadow( | |
1497 gfx::Rect(x, y, width, height)); | |
1498 } | |
1499 | |
1500 void remote_surface_set_title(wl_client* client, | |
1501 wl_resource* resource, | |
1502 const char* title) { | |
1503 GetUserDataAs<ShellSurface>(resource)->SetTitle( | |
1504 base::string16(base::UTF8ToUTF16(title))); | |
1505 } | |
1506 | |
1507 void remote_surface_set_top_inset(wl_client* client, | |
1508 wl_resource* resource, | |
1509 int32_t height) { | |
1510 GetUserDataAs<ShellSurface>(resource)->SetTopInset(height); | |
1511 } | |
1512 | |
1513 void remote_surface_set_system_modal(wl_client* client, wl_resource* resource) { | 1529 void remote_surface_set_system_modal(wl_client* client, wl_resource* resource) { |
1514 GetUserDataAs<ShellSurface>(resource)->SetSystemModal(true); | 1530 GetUserDataAs<ShellSurface>(resource)->SetSystemModal(true); |
1515 } | 1531 } |
1516 | 1532 |
1517 void remote_surface_unset_system_modal(wl_client* client, | 1533 void remote_surface_unset_system_modal(wl_client* client, |
1518 wl_resource* resource) { | 1534 wl_resource* resource) { |
1519 GetUserDataAs<ShellSurface>(resource)->SetSystemModal(false); | 1535 GetUserDataAs<ShellSurface>(resource)->SetSystemModal(false); |
1520 } | 1536 } |
1521 | 1537 |
1522 void remote_surface_set_rectangular_shadow_background_opacity( | 1538 const struct zcr_remote_surface_v1_interface remote_surface_implementation = { |
| 1539 remote_surface_destroy, |
| 1540 remote_surface_set_app_id, |
| 1541 remote_surface_set_window_geometry, |
| 1542 remote_surface_set_scale, |
| 1543 remote_surface_set_rectangular_shadow, |
| 1544 remote_surface_set_rectangular_shadow_background_opacity, |
| 1545 remote_surface_set_title, |
| 1546 remote_surface_set_top_inset, |
| 1547 remote_surface_activate, |
| 1548 remote_surface_maximize, |
| 1549 remote_surface_minimize, |
| 1550 remote_surface_restore, |
| 1551 remote_surface_fullscreen, |
| 1552 remote_surface_unfullscreen, |
| 1553 remote_surface_pin, |
| 1554 remote_surface_unpin, |
| 1555 remote_surface_set_system_modal, |
| 1556 remote_surface_unset_system_modal}; |
| 1557 |
| 1558 void remote_surface_destroy_DEPRECATED(wl_client* client, |
| 1559 wl_resource* resource) { |
| 1560 wl_resource_destroy(resource); |
| 1561 } |
| 1562 |
| 1563 void remote_surface_set_app_id_DEPRECATED(wl_client* client, |
| 1564 wl_resource* resource, |
| 1565 const char* app_id) { |
| 1566 GetUserDataAs<ShellSurface>(resource)->SetApplicationId(app_id); |
| 1567 } |
| 1568 |
| 1569 void remote_surface_set_window_geometry_DEPRECATED(wl_client* client, |
| 1570 wl_resource* resource, |
| 1571 int32_t x, |
| 1572 int32_t y, |
| 1573 int32_t width, |
| 1574 int32_t height) { |
| 1575 GetUserDataAs<ShellSurface>(resource)->SetGeometry( |
| 1576 gfx::Rect(x, y, width, height)); |
| 1577 } |
| 1578 |
| 1579 void remote_surface_set_scale_DEPRECATED(wl_client* client, |
| 1580 wl_resource* resource, |
| 1581 wl_fixed_t scale) { |
| 1582 GetUserDataAs<ShellSurface>(resource)->SetScale(wl_fixed_to_double(scale)); |
| 1583 } |
| 1584 |
| 1585 void remote_surface_fullscreen_DEPRECATED(wl_client* client, |
| 1586 wl_resource* resource) { |
| 1587 GetUserDataAs<ShellSurface>(resource)->SetFullscreen(true); |
| 1588 } |
| 1589 |
| 1590 void remote_surface_maximize_DEPRECATED(wl_client* client, |
| 1591 wl_resource* resource) { |
| 1592 GetUserDataAs<ShellSurface>(resource)->Maximize(); |
| 1593 } |
| 1594 |
| 1595 void remote_surface_minimize_DEPRECATED(wl_client* client, |
| 1596 wl_resource* resource) { |
| 1597 GetUserDataAs<ShellSurface>(resource)->Minimize(); |
| 1598 } |
| 1599 |
| 1600 void remote_surface_restore_DEPRECATED(wl_client* client, |
| 1601 wl_resource* resource) { |
| 1602 GetUserDataAs<ShellSurface>(resource)->Restore(); |
| 1603 } |
| 1604 |
| 1605 void remote_surface_pin_DEPRECATED(wl_client* client, wl_resource* resource) { |
| 1606 GetUserDataAs<ShellSurface>(resource)->SetPinned(true); |
| 1607 } |
| 1608 |
| 1609 void remote_surface_unpin_DEPRECATED(wl_client* client, wl_resource* resource) { |
| 1610 GetUserDataAs<ShellSurface>(resource)->SetPinned(false); |
| 1611 } |
| 1612 |
| 1613 void remote_surface_unfullscreen_DEPRECATED(wl_client* client, |
| 1614 wl_resource* resource) { |
| 1615 GetUserDataAs<ShellSurface>(resource)->SetFullscreen(false); |
| 1616 } |
| 1617 |
| 1618 void remote_surface_set_rectangular_shadow_DEPRECATED(wl_client* client, |
| 1619 wl_resource* resource, |
| 1620 int32_t x, |
| 1621 int32_t y, |
| 1622 int32_t width, |
| 1623 int32_t height) { |
| 1624 GetUserDataAs<ShellSurface>(resource)->SetRectangularShadow( |
| 1625 gfx::Rect(x, y, width, height)); |
| 1626 } |
| 1627 |
| 1628 void remote_surface_set_title_DEPRECATED(wl_client* client, |
| 1629 wl_resource* resource, |
| 1630 const char* title) { |
| 1631 GetUserDataAs<ShellSurface>(resource)->SetTitle( |
| 1632 base::string16(base::UTF8ToUTF16(title))); |
| 1633 } |
| 1634 |
| 1635 void remote_surface_set_top_inset_DEPRECATED(wl_client* client, |
| 1636 wl_resource* resource, |
| 1637 int32_t height) { |
| 1638 GetUserDataAs<ShellSurface>(resource)->SetTopInset(height); |
| 1639 } |
| 1640 |
| 1641 void remote_surface_set_system_modal_DEPRECATED(wl_client* client, |
| 1642 wl_resource* resource) { |
| 1643 GetUserDataAs<ShellSurface>(resource)->SetSystemModal(true); |
| 1644 } |
| 1645 |
| 1646 void remote_surface_unset_system_modal_DEPRECATED(wl_client* client, |
| 1647 wl_resource* resource) { |
| 1648 GetUserDataAs<ShellSurface>(resource)->SetSystemModal(false); |
| 1649 } |
| 1650 |
| 1651 void remote_surface_set_rectangular_shadow_background_opacity_DEPRECATED( |
1523 wl_client* client, | 1652 wl_client* client, |
1524 wl_resource* resource, | 1653 wl_resource* resource, |
1525 wl_fixed_t opacity) { | 1654 wl_fixed_t opacity) { |
1526 GetUserDataAs<ShellSurface>(resource)->SetRectangularShadowBackgroundOpacity( | 1655 GetUserDataAs<ShellSurface>(resource)->SetRectangularShadowBackgroundOpacity( |
1527 wl_fixed_to_double(opacity)); | 1656 wl_fixed_to_double(opacity)); |
1528 } | 1657 } |
1529 | 1658 |
1530 void remote_surface_activate(wl_client* client, | 1659 void remote_surface_activate_DEPRECATED(wl_client* client, |
1531 wl_resource* resource, | 1660 wl_resource* resource, |
1532 uint32_t serial) { | 1661 uint32_t serial) { |
1533 GetUserDataAs<ShellSurface>(resource)->Activate(); | 1662 GetUserDataAs<ShellSurface>(resource)->Activate(); |
1534 } | 1663 } |
1535 | 1664 |
1536 const struct zwp_remote_surface_v1_interface remote_surface_implementation = { | 1665 const struct zwp_remote_surface_v1_interface |
1537 remote_surface_destroy, | 1666 remote_surface_implementation_DEPRECATED = { |
1538 remote_surface_set_app_id, | 1667 remote_surface_destroy_DEPRECATED, |
1539 remote_surface_set_window_geometry, | 1668 remote_surface_set_app_id_DEPRECATED, |
1540 remote_surface_set_scale, | 1669 remote_surface_set_window_geometry_DEPRECATED, |
1541 remote_surface_fullscreen, | 1670 remote_surface_set_scale_DEPRECATED, |
1542 remote_surface_maximize, | 1671 remote_surface_fullscreen_DEPRECATED, |
1543 remote_surface_minimize, | 1672 remote_surface_maximize_DEPRECATED, |
1544 remote_surface_restore, | 1673 remote_surface_minimize_DEPRECATED, |
1545 remote_surface_pin, | 1674 remote_surface_restore_DEPRECATED, |
1546 remote_surface_unpin, | 1675 remote_surface_pin_DEPRECATED, |
1547 remote_surface_unfullscreen, | 1676 remote_surface_unpin_DEPRECATED, |
1548 remote_surface_set_rectangular_shadow, | 1677 remote_surface_unfullscreen_DEPRECATED, |
1549 remote_surface_set_title, | 1678 remote_surface_set_rectangular_shadow_DEPRECATED, |
1550 remote_surface_set_top_inset, | 1679 remote_surface_set_title_DEPRECATED, |
1551 remote_surface_set_system_modal, | 1680 remote_surface_set_top_inset_DEPRECATED, |
1552 remote_surface_unset_system_modal, | 1681 remote_surface_set_system_modal_DEPRECATED, |
1553 remote_surface_set_rectangular_shadow_background_opacity, | 1682 remote_surface_unset_system_modal_DEPRECATED, |
1554 remote_surface_activate}; | 1683 remote_surface_set_rectangular_shadow_background_opacity_DEPRECATED, |
| 1684 remote_surface_activate_DEPRECATED}; |
1555 | 1685 |
1556 //////////////////////////////////////////////////////////////////////////////// | 1686 //////////////////////////////////////////////////////////////////////////////// |
1557 // notification_surface_interface: | 1687 // notification_surface_interface: |
1558 | 1688 |
1559 void notification_surface_destroy(wl_client* client, wl_resource* resource) { | 1689 void notification_surface_destroy(wl_client* client, wl_resource* resource) { |
1560 wl_resource_destroy(resource); | 1690 wl_resource_destroy(resource); |
1561 } | 1691 } |
1562 | 1692 |
| 1693 const struct zcr_notification_surface_v1_interface |
| 1694 notification_surface_implementation = {notification_surface_destroy}; |
| 1695 |
| 1696 void notification_surface_destroy_DEPRECATED(wl_client* client, |
| 1697 wl_resource* resource) { |
| 1698 wl_resource_destroy(resource); |
| 1699 } |
| 1700 |
1563 const struct zwp_notification_surface_v1_interface | 1701 const struct zwp_notification_surface_v1_interface |
1564 notification_surface_implementation = {notification_surface_destroy}; | 1702 notification_surface_implementation_DEPRECATED = { |
| 1703 notification_surface_destroy_DEPRECATED}; |
1565 | 1704 |
1566 //////////////////////////////////////////////////////////////////////////////// | 1705 //////////////////////////////////////////////////////////////////////////////// |
1567 // remote_shell_interface: | 1706 // remote_shell_interface: |
1568 | 1707 |
1569 // Implements remote shell interface and monitors workspace state needed | 1708 // Implements remote shell interface and monitors workspace state needed |
1570 // for the remote shell interface. | 1709 // for the remote shell interface. |
1571 class WaylandRemoteShell : public WMHelper::MaximizeModeObserver, | 1710 class WaylandRemoteShell : public WMHelper::MaximizeModeObserver, |
1572 public WMHelper::ActivationObserver, | 1711 public WMHelper::ActivationObserver, |
1573 public display::DisplayObserver { | 1712 public display::DisplayObserver { |
1574 public: | 1713 public: |
1575 WaylandRemoteShell(Display* display, | 1714 WaylandRemoteShell(Display* display, wl_resource* remote_shell_resource) |
1576 wl_resource* remote_shell_resource) | |
1577 : display_(display), | 1715 : display_(display), |
1578 remote_shell_resource_(remote_shell_resource), | 1716 remote_shell_resource_(remote_shell_resource), |
1579 weak_ptr_factory_(this) { | 1717 weak_ptr_factory_(this) { |
| 1718 auto* helper = WMHelper::GetInstance(); |
| 1719 helper->AddMaximizeModeObserver(this); |
| 1720 helper->AddActivationObserver(this); |
| 1721 display::Screen::GetScreen()->AddObserver(this); |
| 1722 |
| 1723 layout_mode_ = helper->IsMaximizeModeWindowManagerEnabled() |
| 1724 ? ZCR_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET |
| 1725 : ZCR_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED; |
| 1726 |
| 1727 SendPrimaryDisplayMetrics(); |
| 1728 SendActivated(helper->GetActiveWindow(), nullptr); |
| 1729 } |
| 1730 ~WaylandRemoteShell() override { |
| 1731 auto* helper = WMHelper::GetInstance(); |
| 1732 helper->RemoveMaximizeModeObserver(this); |
| 1733 helper->RemoveActivationObserver(this); |
| 1734 display::Screen::GetScreen()->RemoveObserver(this); |
| 1735 } |
| 1736 |
| 1737 std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface, |
| 1738 int container) { |
| 1739 return display_->CreateRemoteShellSurface(surface, container); |
| 1740 } |
| 1741 |
| 1742 std::unique_ptr<NotificationSurface> CreateNotificationSurface( |
| 1743 Surface* surface, |
| 1744 const std::string& notification_id) { |
| 1745 return display_->CreateNotificationSurface(surface, notification_id); |
| 1746 } |
| 1747 |
| 1748 // Overridden from display::DisplayObserver: |
| 1749 void OnDisplayAdded(const display::Display& new_display) override {} |
| 1750 void OnDisplayRemoved(const display::Display& new_display) override {} |
| 1751 void OnDisplayMetricsChanged(const display::Display& display, |
| 1752 uint32_t changed_metrics) override { |
| 1753 if (display::Screen::GetScreen()->GetPrimaryDisplay().id() != display.id()) |
| 1754 return; |
| 1755 |
| 1756 // No need to update when a primary dislpay has changed without bounds |
| 1757 // change. See WaylandPrimaryDisplayObserver::OnDisplayMetricsChanged |
| 1758 // for more details. |
| 1759 if (changed_metrics & |
| 1760 (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_DEVICE_SCALE_FACTOR | |
| 1761 DISPLAY_METRIC_ROTATION | DISPLAY_METRIC_WORK_AREA)) { |
| 1762 SendDisplayMetrics(display); |
| 1763 } |
| 1764 } |
| 1765 |
| 1766 // Overridden from WMHelper::MaximizeModeObserver: |
| 1767 void OnMaximizeModeStarted() override { |
| 1768 layout_mode_ = ZCR_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET; |
| 1769 |
| 1770 send_configure_after_layout_change_ = true; |
| 1771 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 1772 FROM_HERE, base::Bind(&WaylandRemoteShell::MaybeSendConfigure, |
| 1773 weak_ptr_factory_.GetWeakPtr()), |
| 1774 base::TimeDelta::FromMilliseconds(kConfigureDelayAfterLayoutSwitchMs)); |
| 1775 } |
| 1776 void OnMaximizeModeEnded() override { |
| 1777 layout_mode_ = ZCR_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED; |
| 1778 send_configure_after_layout_change_ = true; |
| 1779 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 1780 FROM_HERE, base::Bind(&WaylandRemoteShell::MaybeSendConfigure, |
| 1781 weak_ptr_factory_.GetWeakPtr()), |
| 1782 base::TimeDelta::FromMilliseconds(kConfigureDelayAfterLayoutSwitchMs)); |
| 1783 } |
| 1784 |
| 1785 // Overridden from WMHelper::ActivationObserver: |
| 1786 void OnWindowActivated(aura::Window* gained_active, |
| 1787 aura::Window* lost_active) override { |
| 1788 SendActivated(gained_active, lost_active); |
| 1789 } |
| 1790 |
| 1791 private: |
| 1792 void SendPrimaryDisplayMetrics() { |
| 1793 const display::Display primary = |
| 1794 display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 1795 |
| 1796 SendDisplayMetrics(primary); |
| 1797 } |
| 1798 |
| 1799 void MaybeSendConfigure() { |
| 1800 if (send_configure_after_layout_change_) |
| 1801 SendPrimaryDisplayMetrics(); |
| 1802 } |
| 1803 |
| 1804 void SendDisplayMetrics(const display::Display& display) { |
| 1805 send_configure_after_layout_change_ = false; |
| 1806 |
| 1807 const gfx::Insets& work_area_insets = display.GetWorkAreaInsets(); |
| 1808 |
| 1809 zcr_remote_shell_v1_send_configuration_changed( |
| 1810 remote_shell_resource_, display.size().width(), display.size().height(), |
| 1811 OutputTransform(display.rotation()), |
| 1812 wl_fixed_from_double(display.device_scale_factor()), |
| 1813 work_area_insets.left(), work_area_insets.top(), |
| 1814 work_area_insets.right(), work_area_insets.bottom(), layout_mode_); |
| 1815 wl_client_flush(wl_resource_get_client(remote_shell_resource_)); |
| 1816 } |
| 1817 |
| 1818 void SendActivated(aura::Window* gained_active, aura::Window* lost_active) { |
| 1819 Surface* gained_active_surface = |
| 1820 gained_active ? ShellSurface::GetMainSurface(gained_active) : nullptr; |
| 1821 Surface* lost_active_surface = |
| 1822 lost_active ? ShellSurface::GetMainSurface(lost_active) : nullptr; |
| 1823 wl_resource* gained_active_surface_resource = |
| 1824 gained_active_surface ? GetSurfaceResource(gained_active_surface) |
| 1825 : nullptr; |
| 1826 wl_resource* lost_active_surface_resource = |
| 1827 lost_active_surface ? GetSurfaceResource(lost_active_surface) : nullptr; |
| 1828 |
| 1829 wl_client* client = wl_resource_get_client(remote_shell_resource_); |
| 1830 |
| 1831 // If surface that gained active is not owned by remote shell client then |
| 1832 // set it to null. |
| 1833 if (gained_active_surface_resource && |
| 1834 wl_resource_get_client(gained_active_surface_resource) != client) { |
| 1835 gained_active_surface_resource = nullptr; |
| 1836 } |
| 1837 |
| 1838 // If surface that lost active is not owned by remote shell client then |
| 1839 // set it to null. |
| 1840 if (lost_active_surface_resource && |
| 1841 wl_resource_get_client(lost_active_surface_resource) != client) { |
| 1842 lost_active_surface_resource = nullptr; |
| 1843 } |
| 1844 |
| 1845 zcr_remote_shell_v1_send_activated(remote_shell_resource_, |
| 1846 gained_active_surface_resource, |
| 1847 lost_active_surface_resource); |
| 1848 wl_client_flush(client); |
| 1849 } |
| 1850 |
| 1851 // The exo display instance. Not owned. |
| 1852 Display* const display_; |
| 1853 |
| 1854 // The remote shell resource associated with observer. |
| 1855 wl_resource* const remote_shell_resource_; |
| 1856 |
| 1857 bool send_configure_after_layout_change_ = false; |
| 1858 |
| 1859 int layout_mode_ = ZCR_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED; |
| 1860 |
| 1861 base::WeakPtrFactory<WaylandRemoteShell> weak_ptr_factory_; |
| 1862 |
| 1863 DISALLOW_COPY_AND_ASSIGN(WaylandRemoteShell); |
| 1864 }; |
| 1865 |
| 1866 void remote_shell_destroy(wl_client* client, wl_resource* resource) { |
| 1867 // Nothing to do here. |
| 1868 } |
| 1869 |
| 1870 int RemoteSurfaceContainer(uint32_t container) { |
| 1871 switch (container) { |
| 1872 case ZCR_REMOTE_SHELL_V1_CONTAINER_DEFAULT: |
| 1873 return ash::kShellWindowId_DefaultContainer; |
| 1874 case ZCR_REMOTE_SHELL_V1_CONTAINER_OVERLAY: |
| 1875 return ash::kShellWindowId_SystemModalContainer; |
| 1876 default: |
| 1877 DLOG(WARNING) << "Unsupported container: " << container; |
| 1878 return ash::kShellWindowId_DefaultContainer; |
| 1879 } |
| 1880 } |
| 1881 |
| 1882 void HandleRemoteSurfaceCloseCallback(wl_resource* resource) { |
| 1883 zcr_remote_surface_v1_send_close(resource); |
| 1884 wl_client_flush(wl_resource_get_client(resource)); |
| 1885 } |
| 1886 |
| 1887 void HandleRemoteSurfaceStateChangedCallback( |
| 1888 wl_resource* resource, |
| 1889 ash::wm::WindowStateType old_state_type, |
| 1890 ash::wm::WindowStateType new_state_type) { |
| 1891 DCHECK_NE(old_state_type, new_state_type); |
| 1892 |
| 1893 uint32_t state_type = ZCR_REMOTE_SHELL_V1_STATE_TYPE_NORMAL; |
| 1894 switch (new_state_type) { |
| 1895 case ash::wm::WINDOW_STATE_TYPE_MINIMIZED: |
| 1896 state_type = ZCR_REMOTE_SHELL_V1_STATE_TYPE_MINIMIZED; |
| 1897 break; |
| 1898 case ash::wm::WINDOW_STATE_TYPE_MAXIMIZED: |
| 1899 state_type = ZCR_REMOTE_SHELL_V1_STATE_TYPE_MAXIMIZED; |
| 1900 break; |
| 1901 case ash::wm::WINDOW_STATE_TYPE_FULLSCREEN: |
| 1902 state_type = ZCR_REMOTE_SHELL_V1_STATE_TYPE_FULLSCREEN; |
| 1903 break; |
| 1904 case ash::wm::WINDOW_STATE_TYPE_PINNED: |
| 1905 state_type = ZCR_REMOTE_SHELL_V1_STATE_TYPE_PINNED; |
| 1906 break; |
| 1907 default: |
| 1908 break; |
| 1909 } |
| 1910 |
| 1911 zcr_remote_surface_v1_send_state_type_changed(resource, state_type); |
| 1912 wl_client_flush(wl_resource_get_client(resource)); |
| 1913 } |
| 1914 |
| 1915 void remote_shell_get_remote_surface(wl_client* client, |
| 1916 wl_resource* resource, |
| 1917 uint32_t id, |
| 1918 wl_resource* surface, |
| 1919 uint32_t container) { |
| 1920 std::unique_ptr<ShellSurface> shell_surface = |
| 1921 GetUserDataAs<WaylandRemoteShell>(resource)->CreateShellSurface( |
| 1922 GetUserDataAs<Surface>(surface), RemoteSurfaceContainer(container)); |
| 1923 if (!shell_surface) { |
| 1924 wl_resource_post_error(resource, ZCR_REMOTE_SHELL_V1_ERROR_ROLE, |
| 1925 "surface has already been assigned a role"); |
| 1926 return; |
| 1927 } |
| 1928 |
| 1929 wl_resource* remote_surface_resource = |
| 1930 wl_resource_create(client, &zcr_remote_surface_v1_interface, |
| 1931 wl_resource_get_version(resource), id); |
| 1932 |
| 1933 shell_surface->set_close_callback( |
| 1934 base::Bind(&HandleRemoteSurfaceCloseCallback, |
| 1935 base::Unretained(remote_surface_resource))); |
| 1936 shell_surface->set_state_changed_callback( |
| 1937 base::Bind(&HandleRemoteSurfaceStateChangedCallback, |
| 1938 base::Unretained(remote_surface_resource))); |
| 1939 |
| 1940 SetImplementation(remote_surface_resource, &remote_surface_implementation, |
| 1941 std::move(shell_surface)); |
| 1942 } |
| 1943 |
| 1944 void remote_shell_get_notification_surface(wl_client* client, |
| 1945 wl_resource* resource, |
| 1946 uint32_t id, |
| 1947 wl_resource* surface, |
| 1948 const char* notification_id) { |
| 1949 if (GetUserDataAs<Surface>(surface)->HasSurfaceDelegate()) { |
| 1950 wl_resource_post_error(resource, ZCR_REMOTE_SHELL_V1_ERROR_ROLE, |
| 1951 "surface has already been assigned a role"); |
| 1952 return; |
| 1953 } |
| 1954 |
| 1955 std::unique_ptr<NotificationSurface> notification_surface = |
| 1956 GetUserDataAs<WaylandRemoteShell>(resource)->CreateNotificationSurface( |
| 1957 GetUserDataAs<Surface>(surface), std::string(notification_id)); |
| 1958 if (!notification_surface) { |
| 1959 wl_resource_post_error(resource, |
| 1960 ZCR_REMOTE_SHELL_V1_ERROR_INVALID_NOTIFICATION_ID, |
| 1961 "invalid notification id"); |
| 1962 return; |
| 1963 } |
| 1964 |
| 1965 wl_resource* notification_surface_resource = |
| 1966 wl_resource_create(client, &zcr_notification_surface_v1_interface, |
| 1967 wl_resource_get_version(resource), id); |
| 1968 SetImplementation(notification_surface_resource, |
| 1969 ¬ification_surface_implementation, |
| 1970 std::move(notification_surface)); |
| 1971 } |
| 1972 |
| 1973 const struct zcr_remote_shell_v1_interface remote_shell_implementation = { |
| 1974 remote_shell_destroy, remote_shell_get_remote_surface, |
| 1975 remote_shell_get_notification_surface}; |
| 1976 |
| 1977 const uint32_t remote_shell_version = 1; |
| 1978 |
| 1979 void bind_remote_shell(wl_client* client, |
| 1980 void* data, |
| 1981 uint32_t version, |
| 1982 uint32_t id) { |
| 1983 wl_resource* resource = |
| 1984 wl_resource_create(client, &zcr_remote_shell_v1_interface, |
| 1985 std::min(version, remote_shell_version), id); |
| 1986 |
| 1987 SetImplementation(resource, &remote_shell_implementation, |
| 1988 base::MakeUnique<WaylandRemoteShell>( |
| 1989 static_cast<Display*>(data), resource)); |
| 1990 } |
| 1991 |
| 1992 // Implements remote shell interface and monitors workspace state needed |
| 1993 // for the remote shell interface. |
| 1994 class WaylandRemoteShell_DEPRECATED : public WMHelper::MaximizeModeObserver, |
| 1995 public WMHelper::ActivationObserver, |
| 1996 public display::DisplayObserver { |
| 1997 public: |
| 1998 WaylandRemoteShell_DEPRECATED(Display* display, |
| 1999 wl_resource* remote_shell_resource) |
| 2000 : display_(display), |
| 2001 remote_shell_resource_(remote_shell_resource), |
| 2002 weak_ptr_factory_(this) { |
1580 auto* helper = WMHelper::GetInstance(); | 2003 auto* helper = WMHelper::GetInstance(); |
1581 helper->AddMaximizeModeObserver(this); | 2004 helper->AddMaximizeModeObserver(this); |
1582 helper->AddActivationObserver(this); | 2005 helper->AddActivationObserver(this); |
1583 display::Screen::GetScreen()->AddObserver(this); | 2006 display::Screen::GetScreen()->AddObserver(this); |
1584 | 2007 |
1585 layout_mode_ = helper->IsMaximizeModeWindowManagerEnabled() | 2008 layout_mode_ = helper->IsMaximizeModeWindowManagerEnabled() |
1586 ? ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET | 2009 ? ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET |
1587 : ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED; | 2010 : ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED; |
1588 | 2011 |
1589 SendPrimaryDisplayMetrics(); | 2012 SendPrimaryDisplayMetrics(); |
1590 SendActivated(helper->GetActiveWindow(), nullptr); | 2013 SendActivated(helper->GetActiveWindow(), nullptr); |
1591 } | 2014 } |
1592 ~WaylandRemoteShell() override { | 2015 ~WaylandRemoteShell_DEPRECATED() override { |
1593 auto* helper = WMHelper::GetInstance(); | 2016 auto* helper = WMHelper::GetInstance(); |
1594 helper->RemoveMaximizeModeObserver(this); | 2017 helper->RemoveMaximizeModeObserver(this); |
1595 helper->RemoveActivationObserver(this); | 2018 helper->RemoveActivationObserver(this); |
1596 display::Screen::GetScreen()->RemoveObserver(this); | 2019 display::Screen::GetScreen()->RemoveObserver(this); |
1597 } | 2020 } |
1598 | 2021 |
1599 std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface, | 2022 std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface, |
1600 int container) { | 2023 int container) { |
1601 return display_->CreateRemoteShellSurface(surface, container); | 2024 return display_->CreateRemoteShellSurface(surface, container); |
1602 } | 2025 } |
(...skipping 23 matching lines...) Expand all Loading... |
1626 SendConfigure_DEPRECATED(display); | 2049 SendConfigure_DEPRECATED(display); |
1627 } | 2050 } |
1628 | 2051 |
1629 // Overridden from WMHelper::MaximizeModeObserver: | 2052 // Overridden from WMHelper::MaximizeModeObserver: |
1630 void OnMaximizeModeStarted() override { | 2053 void OnMaximizeModeStarted() override { |
1631 layout_mode_ = ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET; | 2054 layout_mode_ = ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET; |
1632 SendLayoutModeChange_DEPRECATED(); | 2055 SendLayoutModeChange_DEPRECATED(); |
1633 | 2056 |
1634 send_configure_after_layout_change_ = true; | 2057 send_configure_after_layout_change_ = true; |
1635 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 2058 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
1636 FROM_HERE, base::Bind(&WaylandRemoteShell::MaybeSendConfigure, | 2059 FROM_HERE, |
1637 weak_ptr_factory_.GetWeakPtr()), | 2060 base::Bind(&WaylandRemoteShell_DEPRECATED::MaybeSendConfigure, |
| 2061 weak_ptr_factory_.GetWeakPtr()), |
1638 base::TimeDelta::FromMilliseconds(kConfigureDelayAfterLayoutSwitchMs)); | 2062 base::TimeDelta::FromMilliseconds(kConfigureDelayAfterLayoutSwitchMs)); |
1639 } | 2063 } |
1640 void OnMaximizeModeEnded() override { | 2064 void OnMaximizeModeEnded() override { |
1641 layout_mode_ = ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED; | 2065 layout_mode_ = ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED; |
1642 SendLayoutModeChange_DEPRECATED(); | 2066 SendLayoutModeChange_DEPRECATED(); |
1643 send_configure_after_layout_change_ = true; | 2067 send_configure_after_layout_change_ = true; |
1644 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 2068 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
1645 FROM_HERE, base::Bind(&WaylandRemoteShell::MaybeSendConfigure, | 2069 FROM_HERE, |
1646 weak_ptr_factory_.GetWeakPtr()), | 2070 base::Bind(&WaylandRemoteShell_DEPRECATED::MaybeSendConfigure, |
| 2071 weak_ptr_factory_.GetWeakPtr()), |
1647 base::TimeDelta::FromMilliseconds(kConfigureDelayAfterLayoutSwitchMs)); | 2072 base::TimeDelta::FromMilliseconds(kConfigureDelayAfterLayoutSwitchMs)); |
1648 } | 2073 } |
1649 | 2074 |
1650 // Overridden from WMHelper::ActivationObserver: | 2075 // Overridden from WMHelper::ActivationObserver: |
1651 void OnWindowActivated( | 2076 void OnWindowActivated( |
1652 aura::Window* gained_active, | 2077 aura::Window* gained_active, |
1653 aura::Window* lost_active) override { | 2078 aura::Window* lost_active) override { |
1654 SendActivated(gained_active, lost_active); | 2079 SendActivated(gained_active, lost_active); |
1655 } | 2080 } |
1656 | 2081 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1744 // The exo display instance. Not owned. | 2169 // The exo display instance. Not owned. |
1745 Display* const display_; | 2170 Display* const display_; |
1746 | 2171 |
1747 // The remote shell resource associated with observer. | 2172 // The remote shell resource associated with observer. |
1748 wl_resource* const remote_shell_resource_; | 2173 wl_resource* const remote_shell_resource_; |
1749 | 2174 |
1750 bool send_configure_after_layout_change_ = false; | 2175 bool send_configure_after_layout_change_ = false; |
1751 | 2176 |
1752 int layout_mode_ = ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED; | 2177 int layout_mode_ = ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED; |
1753 | 2178 |
1754 base::WeakPtrFactory<WaylandRemoteShell> weak_ptr_factory_; | 2179 base::WeakPtrFactory<WaylandRemoteShell_DEPRECATED> weak_ptr_factory_; |
1755 | 2180 |
1756 DISALLOW_COPY_AND_ASSIGN(WaylandRemoteShell); | 2181 DISALLOW_COPY_AND_ASSIGN(WaylandRemoteShell_DEPRECATED); |
1757 }; | 2182 }; |
1758 | 2183 |
1759 void remote_shell_destroy(wl_client* client, wl_resource* resource) { | 2184 void remote_shell_destroy_DEPRECATED(wl_client* client, wl_resource* resource) { |
1760 // Nothing to do here. | 2185 // Nothing to do here. |
1761 } | 2186 } |
1762 | 2187 |
1763 int RemoteSurfaceContainer(uint32_t container) { | 2188 int RemoteSurfaceContainer_DEPRECATED(uint32_t container) { |
1764 switch (container) { | 2189 switch (container) { |
1765 case ZWP_REMOTE_SHELL_V1_CONTAINER_DEFAULT: | 2190 case ZWP_REMOTE_SHELL_V1_CONTAINER_DEFAULT: |
1766 return ash::kShellWindowId_DefaultContainer; | 2191 return ash::kShellWindowId_DefaultContainer; |
1767 case ZWP_REMOTE_SHELL_V1_CONTAINER_OVERLAY: | 2192 case ZWP_REMOTE_SHELL_V1_CONTAINER_OVERLAY: |
1768 return ash::kShellWindowId_SystemModalContainer; | 2193 return ash::kShellWindowId_SystemModalContainer; |
1769 default: | 2194 default: |
1770 DLOG(WARNING) << "Unsupported container: " << container; | 2195 DLOG(WARNING) << "Unsupported container: " << container; |
1771 return ash::kShellWindowId_DefaultContainer; | 2196 return ash::kShellWindowId_DefaultContainer; |
1772 } | 2197 } |
1773 } | 2198 } |
1774 | 2199 |
1775 void HandleRemoteSurfaceCloseCallback(wl_resource* resource) { | 2200 void HandleRemoteSurfaceCloseCallback_DEPRECATED(wl_resource* resource) { |
1776 zwp_remote_surface_v1_send_close(resource); | 2201 zwp_remote_surface_v1_send_close(resource); |
1777 wl_client_flush(wl_resource_get_client(resource)); | 2202 wl_client_flush(wl_resource_get_client(resource)); |
1778 } | 2203 } |
1779 | 2204 |
1780 void HandleRemoteSurfaceStateChangedCallback( | 2205 void HandleRemoteSurfaceStateChangedCallback_DEPRECATED( |
1781 wl_resource* resource, | 2206 wl_resource* resource, |
1782 ash::wm::WindowStateType old_state_type, | 2207 ash::wm::WindowStateType old_state_type, |
1783 ash::wm::WindowStateType new_state_type) { | 2208 ash::wm::WindowStateType new_state_type) { |
1784 DCHECK_NE(old_state_type, new_state_type); | 2209 DCHECK_NE(old_state_type, new_state_type); |
1785 | 2210 |
1786 switch (old_state_type) { | 2211 switch (old_state_type) { |
1787 case ash::wm::WINDOW_STATE_TYPE_MINIMIZED: | 2212 case ash::wm::WINDOW_STATE_TYPE_MINIMIZED: |
1788 if (wl_resource_get_version(resource) >= 2) | 2213 if (wl_resource_get_version(resource) >= 2) |
1789 zwp_remote_surface_v1_send_unset_minimized(resource); | 2214 zwp_remote_surface_v1_send_unset_minimized(resource); |
1790 break; | 2215 break; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1827 default: | 2252 default: |
1828 break; | 2253 break; |
1829 } | 2254 } |
1830 | 2255 |
1831 if (wl_resource_get_version(resource) >= 7) | 2256 if (wl_resource_get_version(resource) >= 7) |
1832 zwp_remote_surface_v1_send_state_type_changed(resource, state_type); | 2257 zwp_remote_surface_v1_send_state_type_changed(resource, state_type); |
1833 | 2258 |
1834 wl_client_flush(wl_resource_get_client(resource)); | 2259 wl_client_flush(wl_resource_get_client(resource)); |
1835 } | 2260 } |
1836 | 2261 |
1837 void remote_shell_get_remote_surface(wl_client* client, | 2262 void remote_shell_get_remote_surface_DEPRECATED(wl_client* client, |
1838 wl_resource* resource, | 2263 wl_resource* resource, |
1839 uint32_t id, | 2264 uint32_t id, |
1840 wl_resource* surface, | 2265 wl_resource* surface, |
1841 uint32_t container) { | 2266 uint32_t container) { |
1842 std::unique_ptr<ShellSurface> shell_surface = | 2267 std::unique_ptr<ShellSurface> shell_surface = |
1843 GetUserDataAs<WaylandRemoteShell>(resource)->CreateShellSurface( | 2268 GetUserDataAs<WaylandRemoteShell>(resource)->CreateShellSurface( |
1844 GetUserDataAs<Surface>(surface), RemoteSurfaceContainer(container)); | 2269 GetUserDataAs<Surface>(surface), |
| 2270 RemoteSurfaceContainer_DEPRECATED(container)); |
1845 if (!shell_surface) { | 2271 if (!shell_surface) { |
1846 wl_resource_post_error(resource, ZWP_REMOTE_SHELL_V1_ERROR_ROLE, | 2272 wl_resource_post_error(resource, ZWP_REMOTE_SHELL_V1_ERROR_ROLE, |
1847 "surface has already been assigned a role"); | 2273 "surface has already been assigned a role"); |
1848 return; | 2274 return; |
1849 } | 2275 } |
1850 | 2276 |
1851 wl_resource* remote_surface_resource = | 2277 wl_resource* remote_surface_resource = |
1852 wl_resource_create(client, &zwp_remote_surface_v1_interface, | 2278 wl_resource_create(client, &zwp_remote_surface_v1_interface, |
1853 wl_resource_get_version(resource), id); | 2279 wl_resource_get_version(resource), id); |
1854 | 2280 |
1855 shell_surface->set_close_callback( | 2281 shell_surface->set_close_callback( |
1856 base::Bind(&HandleRemoteSurfaceCloseCallback, | 2282 base::Bind(&HandleRemoteSurfaceCloseCallback_DEPRECATED, |
1857 base::Unretained(remote_surface_resource))); | 2283 base::Unretained(remote_surface_resource))); |
1858 shell_surface->set_state_changed_callback( | 2284 shell_surface->set_state_changed_callback( |
1859 base::Bind(&HandleRemoteSurfaceStateChangedCallback, | 2285 base::Bind(&HandleRemoteSurfaceStateChangedCallback_DEPRECATED, |
1860 base::Unretained(remote_surface_resource))); | 2286 base::Unretained(remote_surface_resource))); |
1861 | 2287 |
1862 SetImplementation(remote_surface_resource, &remote_surface_implementation, | 2288 SetImplementation(remote_surface_resource, |
| 2289 &remote_surface_implementation_DEPRECATED, |
1863 std::move(shell_surface)); | 2290 std::move(shell_surface)); |
1864 } | 2291 } |
1865 | 2292 |
1866 void remote_shell_get_notification_surface(wl_client* client, | 2293 void remote_shell_get_notification_surface_DEPRECATED( |
1867 wl_resource* resource, | 2294 wl_client* client, |
1868 uint32_t id, | 2295 wl_resource* resource, |
1869 wl_resource* surface, | 2296 uint32_t id, |
1870 const char* notification_id) { | 2297 wl_resource* surface, |
| 2298 const char* notification_id) { |
1871 if (GetUserDataAs<Surface>(surface)->HasSurfaceDelegate()) { | 2299 if (GetUserDataAs<Surface>(surface)->HasSurfaceDelegate()) { |
1872 wl_resource_post_error(resource, ZWP_REMOTE_SHELL_V1_ERROR_ROLE, | 2300 wl_resource_post_error(resource, ZWP_REMOTE_SHELL_V1_ERROR_ROLE, |
1873 "surface has already been assigned a role"); | 2301 "surface has already been assigned a role"); |
1874 return; | 2302 return; |
1875 } | 2303 } |
1876 | 2304 |
1877 std::unique_ptr<NotificationSurface> notification_surface = | 2305 std::unique_ptr<NotificationSurface> notification_surface = |
1878 GetUserDataAs<WaylandRemoteShell>(resource)->CreateNotificationSurface( | 2306 GetUserDataAs<WaylandRemoteShell>(resource)->CreateNotificationSurface( |
1879 GetUserDataAs<Surface>(surface), std::string(notification_id)); | 2307 GetUserDataAs<Surface>(surface), std::string(notification_id)); |
1880 if (!notification_surface) { | 2308 if (!notification_surface) { |
1881 wl_resource_post_error(resource, | 2309 wl_resource_post_error(resource, |
1882 ZWP_REMOTE_SHELL_V1_ERROR_INVALID_NOTIFICATION_ID, | 2310 ZWP_REMOTE_SHELL_V1_ERROR_INVALID_NOTIFICATION_ID, |
1883 "invalid notification id"); | 2311 "invalid notification id"); |
1884 return; | 2312 return; |
1885 } | 2313 } |
1886 | 2314 |
1887 wl_resource* notification_surface_resource = | 2315 wl_resource* notification_surface_resource = |
1888 wl_resource_create(client, &zwp_notification_surface_v1_interface, | 2316 wl_resource_create(client, &zwp_notification_surface_v1_interface, |
1889 wl_resource_get_version(resource), id); | 2317 wl_resource_get_version(resource), id); |
1890 SetImplementation(notification_surface_resource, | 2318 SetImplementation(notification_surface_resource, |
1891 ¬ification_surface_implementation, | 2319 ¬ification_surface_implementation_DEPRECATED, |
1892 std::move(notification_surface)); | 2320 std::move(notification_surface)); |
1893 } | 2321 } |
1894 | 2322 |
1895 const struct zwp_remote_shell_v1_interface remote_shell_implementation = { | 2323 const struct zwp_remote_shell_v1_interface |
1896 remote_shell_destroy, remote_shell_get_remote_surface, | 2324 remote_shell_implementation_DEPRECATED = { |
1897 remote_shell_get_notification_surface}; | 2325 remote_shell_destroy_DEPRECATED, |
| 2326 remote_shell_get_remote_surface_DEPRECATED, |
| 2327 remote_shell_get_notification_surface_DEPRECATED}; |
1898 | 2328 |
1899 const uint32_t remote_shell_version = 10; | 2329 const uint32_t remote_shell_version_DEPRECATED = 10; |
1900 | 2330 |
1901 void bind_remote_shell(wl_client* client, | 2331 void bind_remote_shell_DEPRECATED(wl_client* client, |
1902 void* data, | 2332 void* data, |
1903 uint32_t version, | 2333 uint32_t version, |
1904 uint32_t id) { | 2334 uint32_t id) { |
1905 wl_resource* resource = | 2335 wl_resource* resource = wl_resource_create( |
1906 wl_resource_create(client, &zwp_remote_shell_v1_interface, | 2336 client, &zwp_remote_shell_v1_interface, |
1907 std::min(version, remote_shell_version), id); | 2337 std::min(version, remote_shell_version_DEPRECATED), id); |
1908 | 2338 |
1909 SetImplementation(resource, &remote_shell_implementation, | 2339 SetImplementation(resource, &remote_shell_implementation_DEPRECATED, |
1910 base::MakeUnique<WaylandRemoteShell>( | 2340 base::MakeUnique<WaylandRemoteShell>( |
1911 static_cast<Display*>(data), resource)); | 2341 static_cast<Display*>(data), resource)); |
1912 } | 2342 } |
1913 | 2343 |
1914 //////////////////////////////////////////////////////////////////////////////// | 2344 //////////////////////////////////////////////////////////////////////////////// |
1915 // zwp_vsync_timing_v1_interface: | 2345 // vsync_timing_interface: |
1916 | 2346 |
1917 // Implements VSync timing interface by monitoring a compositor for updates | 2347 // Implements VSync timing interface by monitoring a compositor for updates |
1918 // to VSync parameters. | 2348 // to VSync parameters. |
1919 class VSyncTiming : public ui::CompositorVSyncManager::Observer { | 2349 class VSyncTiming : public ui::CompositorVSyncManager::Observer { |
1920 public: | 2350 public: |
1921 ~VSyncTiming() { vsync_manager_->RemoveObserver(this); } | 2351 ~VSyncTiming() { vsync_manager_->RemoveObserver(this); } |
1922 | 2352 |
1923 static std::unique_ptr<VSyncTiming> Create(ui::Compositor* compositor, | 2353 static std::unique_ptr<VSyncTiming> Create(ui::Compositor* compositor, |
1924 wl_resource* timing_resource) { | 2354 wl_resource* timing_resource) { |
1925 std::unique_ptr<VSyncTiming> vsync_timing( | 2355 std::unique_ptr<VSyncTiming> vsync_timing( |
(...skipping 21 matching lines...) Expand all Loading... |
1947 static_cast<int64_t>(last_offset_us_ - offset_us); | 2377 static_cast<int64_t>(last_offset_us_ - offset_us); |
1948 | 2378 |
1949 // Reduce the amount of events by only sending an update if the offset | 2379 // Reduce the amount of events by only sending an update if the offset |
1950 // changed compared to the last offset sent to the client by this amount. | 2380 // changed compared to the last offset sent to the client by this amount. |
1951 const int64_t kOffsetDeltaThresholdInMicroseconds = 25; | 2381 const int64_t kOffsetDeltaThresholdInMicroseconds = 25; |
1952 | 2382 |
1953 if (std::abs(offset_delta_us) < kOffsetDeltaThresholdInMicroseconds) | 2383 if (std::abs(offset_delta_us) < kOffsetDeltaThresholdInMicroseconds) |
1954 return; | 2384 return; |
1955 } | 2385 } |
1956 | 2386 |
1957 zwp_vsync_timing_v1_send_update(timing_resource_, timebase_us & 0xffffffff, | 2387 zcr_vsync_timing_v1_send_update(timing_resource_, timebase_us & 0xffffffff, |
1958 timebase_us >> 32, interval_us & 0xffffffff, | 2388 timebase_us >> 32, interval_us & 0xffffffff, |
1959 interval_us >> 32); | 2389 interval_us >> 32); |
1960 wl_client_flush(wl_resource_get_client(timing_resource_)); | 2390 wl_client_flush(wl_resource_get_client(timing_resource_)); |
1961 | 2391 |
1962 last_interval_us_ = interval_us; | 2392 last_interval_us_ = interval_us; |
1963 last_offset_us_ = offset_us; | 2393 last_offset_us_ = offset_us; |
1964 } | 2394 } |
1965 | 2395 |
1966 private: | 2396 private: |
1967 VSyncTiming(ui::Compositor* compositor, wl_resource* timing_resource) | 2397 VSyncTiming(ui::Compositor* compositor, wl_resource* timing_resource) |
1968 : vsync_manager_(compositor->vsync_manager()), | 2398 : vsync_manager_(compositor->vsync_manager()), |
1969 timing_resource_(timing_resource) {} | 2399 timing_resource_(timing_resource) {} |
1970 | 2400 |
1971 // The VSync manager being observed. | 2401 // The VSync manager being observed. |
1972 scoped_refptr<ui::CompositorVSyncManager> vsync_manager_; | 2402 scoped_refptr<ui::CompositorVSyncManager> vsync_manager_; |
1973 | 2403 |
1974 // The VSync timing resource. | 2404 // The VSync timing resource. |
1975 wl_resource* const timing_resource_; | 2405 wl_resource* const timing_resource_; |
1976 | 2406 |
1977 uint64_t last_interval_us_{0}; | 2407 uint64_t last_interval_us_{0}; |
1978 uint64_t last_offset_us_{0}; | 2408 uint64_t last_offset_us_{0}; |
1979 | 2409 |
1980 DISALLOW_COPY_AND_ASSIGN(VSyncTiming); | 2410 DISALLOW_COPY_AND_ASSIGN(VSyncTiming); |
1981 }; | 2411 }; |
1982 | 2412 |
1983 void vsync_timing_destroy(wl_client* client, wl_resource* resource) { | 2413 void vsync_timing_destroy(wl_client* client, wl_resource* resource) { |
1984 wl_resource_destroy(resource); | 2414 wl_resource_destroy(resource); |
1985 } | 2415 } |
1986 | 2416 |
1987 const struct zwp_vsync_timing_v1_interface vsync_timing_implementation = { | 2417 const struct zcr_vsync_timing_v1_interface vsync_timing_implementation = { |
1988 vsync_timing_destroy}; | 2418 vsync_timing_destroy}; |
1989 | 2419 |
| 2420 // Implements VSync timing interface by monitoring a compositor for updates |
| 2421 // to VSync parameters. |
| 2422 class VSyncTiming_DEPRECATED : public ui::CompositorVSyncManager::Observer { |
| 2423 public: |
| 2424 ~VSyncTiming_DEPRECATED() { vsync_manager_->RemoveObserver(this); } |
| 2425 |
| 2426 static std::unique_ptr<VSyncTiming_DEPRECATED> Create( |
| 2427 ui::Compositor* compositor, |
| 2428 wl_resource* timing_resource) { |
| 2429 std::unique_ptr<VSyncTiming_DEPRECATED> vsync_timing( |
| 2430 new VSyncTiming_DEPRECATED(compositor, timing_resource)); |
| 2431 // Note: AddObserver() will call OnUpdateVSyncParameters. |
| 2432 vsync_timing->vsync_manager_->AddObserver(vsync_timing.get()); |
| 2433 return vsync_timing; |
| 2434 } |
| 2435 |
| 2436 // Overridden from ui::CompositorVSyncManager::Observer: |
| 2437 void OnUpdateVSyncParameters(base::TimeTicks timebase, |
| 2438 base::TimeDelta interval) override { |
| 2439 uint64_t timebase_us = timebase.ToInternalValue(); |
| 2440 uint64_t interval_us = interval.ToInternalValue(); |
| 2441 |
| 2442 // Ignore updates with interval 0. |
| 2443 if (!interval_us) |
| 2444 return; |
| 2445 |
| 2446 uint64_t offset_us = timebase_us % interval_us; |
| 2447 |
| 2448 // Avoid sending update events if interval did not change. |
| 2449 if (interval_us == last_interval_us_) { |
| 2450 int64_t offset_delta_us = |
| 2451 static_cast<int64_t>(last_offset_us_ - offset_us); |
| 2452 |
| 2453 // Reduce the amount of events by only sending an update if the offset |
| 2454 // changed compared to the last offset sent to the client by this amount. |
| 2455 const int64_t kOffsetDeltaThresholdInMicroseconds = 25; |
| 2456 |
| 2457 if (std::abs(offset_delta_us) < kOffsetDeltaThresholdInMicroseconds) |
| 2458 return; |
| 2459 } |
| 2460 |
| 2461 zwp_vsync_timing_v1_send_update(timing_resource_, timebase_us & 0xffffffff, |
| 2462 timebase_us >> 32, interval_us & 0xffffffff, |
| 2463 interval_us >> 32); |
| 2464 wl_client_flush(wl_resource_get_client(timing_resource_)); |
| 2465 |
| 2466 last_interval_us_ = interval_us; |
| 2467 last_offset_us_ = offset_us; |
| 2468 } |
| 2469 |
| 2470 private: |
| 2471 VSyncTiming_DEPRECATED(ui::Compositor* compositor, |
| 2472 wl_resource* timing_resource) |
| 2473 : vsync_manager_(compositor->vsync_manager()), |
| 2474 timing_resource_(timing_resource) {} |
| 2475 |
| 2476 // The VSync manager being observed. |
| 2477 scoped_refptr<ui::CompositorVSyncManager> vsync_manager_; |
| 2478 |
| 2479 // The VSync timing resource. |
| 2480 wl_resource* const timing_resource_; |
| 2481 |
| 2482 uint64_t last_interval_us_{0}; |
| 2483 uint64_t last_offset_us_{0}; |
| 2484 |
| 2485 DISALLOW_COPY_AND_ASSIGN(VSyncTiming_DEPRECATED); |
| 2486 }; |
| 2487 |
| 2488 void vsync_timing_destroy_DEPRECATED(wl_client* client, wl_resource* resource) { |
| 2489 wl_resource_destroy(resource); |
| 2490 } |
| 2491 |
| 2492 const struct zwp_vsync_timing_v1_interface |
| 2493 vsync_timing_implementation_DEPRECATED = {vsync_timing_destroy_DEPRECATED}; |
| 2494 |
1990 //////////////////////////////////////////////////////////////////////////////// | 2495 //////////////////////////////////////////////////////////////////////////////// |
1991 // zwp_vsync_feedback_v1_interface: | 2496 // vsync_feedback_interface: |
1992 | 2497 |
1993 void vsync_feedback_destroy(wl_client* client, wl_resource* resource) { | 2498 void vsync_feedback_destroy(wl_client* client, wl_resource* resource) { |
1994 wl_resource_destroy(resource); | 2499 wl_resource_destroy(resource); |
1995 } | 2500 } |
1996 | 2501 |
1997 void vsync_feedback_get_vsync_timing(wl_client* client, | 2502 void vsync_feedback_get_vsync_timing(wl_client* client, |
1998 wl_resource* resource, | 2503 wl_resource* resource, |
1999 uint32_t id, | 2504 uint32_t id, |
2000 wl_resource* output) { | 2505 wl_resource* output) { |
2001 wl_resource* timing_resource = | 2506 wl_resource* timing_resource = |
| 2507 wl_resource_create(client, &zcr_vsync_timing_v1_interface, 1, id); |
| 2508 |
| 2509 // TODO(reveman): Multi-display support. |
| 2510 ui::Compositor* compositor = |
| 2511 ash::Shell::GetPrimaryRootWindow()->layer()->GetCompositor(); |
| 2512 |
| 2513 SetImplementation(timing_resource, &vsync_timing_implementation, |
| 2514 VSyncTiming::Create(compositor, timing_resource)); |
| 2515 } |
| 2516 |
| 2517 const struct zcr_vsync_feedback_v1_interface vsync_feedback_implementation = { |
| 2518 vsync_feedback_destroy, vsync_feedback_get_vsync_timing}; |
| 2519 |
| 2520 void bind_vsync_feedback(wl_client* client, |
| 2521 void* data, |
| 2522 uint32_t version, |
| 2523 uint32_t id) { |
| 2524 wl_resource* resource = |
| 2525 wl_resource_create(client, &zcr_vsync_feedback_v1_interface, 1, id); |
| 2526 |
| 2527 wl_resource_set_implementation(resource, &vsync_feedback_implementation, |
| 2528 nullptr, nullptr); |
| 2529 } |
| 2530 |
| 2531 void vsync_feedback_destroy_DEPRECATED(wl_client* client, |
| 2532 wl_resource* resource) { |
| 2533 wl_resource_destroy(resource); |
| 2534 } |
| 2535 |
| 2536 void vsync_feedback_get_vsync_timing_DEPRECATED(wl_client* client, |
| 2537 wl_resource* resource, |
| 2538 uint32_t id, |
| 2539 wl_resource* output) { |
| 2540 wl_resource* timing_resource = |
2002 wl_resource_create(client, &zwp_vsync_timing_v1_interface, 1, id); | 2541 wl_resource_create(client, &zwp_vsync_timing_v1_interface, 1, id); |
2003 | 2542 |
2004 // TODO(reveman): Multi-display support. | 2543 // TODO(reveman): Multi-display support. |
2005 ui::Compositor* compositor = | 2544 ui::Compositor* compositor = |
2006 ash::Shell::GetPrimaryRootWindow()->layer()->GetCompositor(); | 2545 ash::Shell::GetPrimaryRootWindow()->layer()->GetCompositor(); |
2007 | 2546 |
2008 SetImplementation(timing_resource, &vsync_timing_implementation, | 2547 SetImplementation(timing_resource, &vsync_timing_implementation_DEPRECATED, |
2009 VSyncTiming::Create(compositor, timing_resource)); | 2548 VSyncTiming::Create(compositor, timing_resource)); |
2010 } | 2549 } |
2011 | 2550 |
2012 const struct zwp_vsync_feedback_v1_interface vsync_feedback_implementation = { | 2551 const struct zwp_vsync_feedback_v1_interface |
2013 vsync_feedback_destroy, vsync_feedback_get_vsync_timing}; | 2552 vsync_feedback_implementation_DEPRECATED = { |
| 2553 vsync_feedback_destroy_DEPRECATED, |
| 2554 vsync_feedback_get_vsync_timing_DEPRECATED}; |
2014 | 2555 |
2015 void bind_vsync_feedback(wl_client* client, | 2556 void bind_vsync_feedback_DEPRECATED(wl_client* client, |
2016 void* data, | 2557 void* data, |
2017 uint32_t version, | 2558 uint32_t version, |
2018 uint32_t id) { | 2559 uint32_t id) { |
2019 wl_resource* resource = | 2560 wl_resource* resource = |
2020 wl_resource_create(client, &zwp_vsync_feedback_v1_interface, 1, id); | 2561 wl_resource_create(client, &zwp_vsync_feedback_v1_interface, 1, id); |
2021 | 2562 |
2022 wl_resource_set_implementation(resource, &vsync_feedback_implementation, | 2563 wl_resource_set_implementation( |
2023 nullptr, nullptr); | 2564 resource, &vsync_feedback_implementation_DEPRECATED, nullptr, nullptr); |
2024 } | 2565 } |
2025 | 2566 |
2026 //////////////////////////////////////////////////////////////////////////////// | 2567 //////////////////////////////////////////////////////////////////////////////// |
2027 // wl_data_device_interface: | 2568 // wl_data_device_interface: |
2028 | 2569 |
2029 void data_device_start_drag(wl_client* client, | 2570 void data_device_start_drag(wl_client* client, |
2030 wl_resource* resource, | 2571 wl_resource* resource, |
2031 wl_resource* source_resource, | 2572 wl_resource* source_resource, |
2032 wl_resource* origin_resource, | 2573 wl_resource* origin_resource, |
2033 wl_resource* icon_resource, | 2574 wl_resource* icon_resource, |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2688 | 3229 |
2689 void security_destroy(wl_client* client, wl_resource* resource) { | 3230 void security_destroy(wl_client* client, wl_resource* resource) { |
2690 wl_resource_destroy(resource); | 3231 wl_resource_destroy(resource); |
2691 } | 3232 } |
2692 | 3233 |
2693 void security_only_visible_on_secure_output(wl_client* client, | 3234 void security_only_visible_on_secure_output(wl_client* client, |
2694 wl_resource* resource) { | 3235 wl_resource* resource) { |
2695 GetUserDataAs<Security>(resource)->OnlyVisibleOnSecureOutput(); | 3236 GetUserDataAs<Security>(resource)->OnlyVisibleOnSecureOutput(); |
2696 } | 3237 } |
2697 | 3238 |
2698 const struct zwp_security_v1_interface security_implementation = { | 3239 const struct zcr_security_v1_interface security_implementation = { |
2699 security_destroy, security_only_visible_on_secure_output}; | 3240 security_destroy, security_only_visible_on_secure_output}; |
2700 | 3241 |
| 3242 void security_destroy_DEPRECATED(wl_client* client, wl_resource* resource) { |
| 3243 wl_resource_destroy(resource); |
| 3244 } |
| 3245 |
| 3246 void security_only_visible_on_secure_output_DEPRECATED(wl_client* client, |
| 3247 wl_resource* resource) { |
| 3248 GetUserDataAs<Security>(resource)->OnlyVisibleOnSecureOutput(); |
| 3249 } |
| 3250 |
| 3251 const struct zwp_security_v1_interface security_implementation_DEPRECATED = { |
| 3252 security_destroy_DEPRECATED, |
| 3253 security_only_visible_on_secure_output_DEPRECATED}; |
| 3254 |
2701 //////////////////////////////////////////////////////////////////////////////// | 3255 //////////////////////////////////////////////////////////////////////////////// |
2702 // secure_output_interface: | 3256 // secure_output_interface: |
2703 | 3257 |
2704 void secure_output_destroy(wl_client* client, wl_resource* resource) { | 3258 void secure_output_destroy(wl_client* client, wl_resource* resource) { |
2705 wl_resource_destroy(resource); | 3259 wl_resource_destroy(resource); |
2706 } | 3260 } |
2707 | 3261 |
2708 void secure_output_get_security(wl_client* client, | 3262 void secure_output_get_security(wl_client* client, |
2709 wl_resource* resource, | 3263 wl_resource* resource, |
2710 uint32_t id, | 3264 uint32_t id, |
2711 wl_resource* surface_resource) { | 3265 wl_resource* surface_resource) { |
2712 Surface* surface = GetUserDataAs<Surface>(surface_resource); | 3266 Surface* surface = GetUserDataAs<Surface>(surface_resource); |
2713 if (surface->GetProperty(kSurfaceHasSecurityKey)) { | 3267 if (surface->GetProperty(kSurfaceHasSecurityKey)) { |
2714 wl_resource_post_error(resource, ZWP_SECURE_OUTPUT_V1_ERROR_SECURITY_EXISTS, | 3268 wl_resource_post_error(resource, ZCR_SECURE_OUTPUT_V1_ERROR_SECURITY_EXISTS, |
2715 "a security object for that surface already exists"); | 3269 "a security object for that surface already exists"); |
2716 return; | 3270 return; |
2717 } | 3271 } |
2718 | 3272 |
2719 wl_resource* security_resource = | 3273 wl_resource* security_resource = |
2720 wl_resource_create(client, &zwp_security_v1_interface, 1, id); | 3274 wl_resource_create(client, &zcr_security_v1_interface, 1, id); |
2721 | 3275 |
2722 SetImplementation(security_resource, &security_implementation, | 3276 SetImplementation(security_resource, &security_implementation, |
2723 base::MakeUnique<Security>(surface)); | 3277 base::MakeUnique<Security>(surface)); |
2724 } | 3278 } |
2725 | 3279 |
2726 const struct zwp_secure_output_v1_interface secure_output_implementation = { | 3280 const struct zcr_secure_output_v1_interface secure_output_implementation = { |
2727 secure_output_destroy, secure_output_get_security}; | 3281 secure_output_destroy, secure_output_get_security}; |
2728 | 3282 |
2729 void bind_secure_output(wl_client* client, | 3283 void bind_secure_output(wl_client* client, |
2730 void* data, | 3284 void* data, |
2731 uint32_t version, | 3285 uint32_t version, |
2732 uint32_t id) { | 3286 uint32_t id) { |
2733 wl_resource* resource = | 3287 wl_resource* resource = |
2734 wl_resource_create(client, &zwp_secure_output_v1_interface, 1, id); | 3288 wl_resource_create(client, &zcr_secure_output_v1_interface, 1, id); |
2735 | 3289 |
2736 wl_resource_set_implementation(resource, &secure_output_implementation, data, | 3290 wl_resource_set_implementation(resource, &secure_output_implementation, data, |
2737 nullptr); | 3291 nullptr); |
2738 } | 3292 } |
2739 | 3293 |
| 3294 void secure_output_destroy_DEPRECATED(wl_client* client, |
| 3295 wl_resource* resource) { |
| 3296 wl_resource_destroy(resource); |
| 3297 } |
| 3298 |
| 3299 void secure_output_get_security_DEPRECATED(wl_client* client, |
| 3300 wl_resource* resource, |
| 3301 uint32_t id, |
| 3302 wl_resource* surface_resource) { |
| 3303 Surface* surface = GetUserDataAs<Surface>(surface_resource); |
| 3304 if (surface->GetProperty(kSurfaceHasSecurityKey)) { |
| 3305 wl_resource_post_error(resource, ZWP_SECURE_OUTPUT_V1_ERROR_SECURITY_EXISTS, |
| 3306 "a security object for that surface already exists"); |
| 3307 return; |
| 3308 } |
| 3309 |
| 3310 wl_resource* security_resource = |
| 3311 wl_resource_create(client, &zwp_security_v1_interface, 1, id); |
| 3312 |
| 3313 SetImplementation(security_resource, &security_implementation_DEPRECATED, |
| 3314 base::MakeUnique<Security>(surface)); |
| 3315 } |
| 3316 |
| 3317 const struct zwp_secure_output_v1_interface |
| 3318 secure_output_implementation_DEPRECATED = { |
| 3319 secure_output_destroy_DEPRECATED, |
| 3320 secure_output_get_security_DEPRECATED}; |
| 3321 |
| 3322 void bind_secure_output_DEPRECATED(wl_client* client, |
| 3323 void* data, |
| 3324 uint32_t version, |
| 3325 uint32_t id) { |
| 3326 wl_resource* resource = |
| 3327 wl_resource_create(client, &zwp_secure_output_v1_interface, 1, id); |
| 3328 |
| 3329 wl_resource_set_implementation( |
| 3330 resource, &secure_output_implementation_DEPRECATED, data, nullptr); |
| 3331 } |
| 3332 |
2740 //////////////////////////////////////////////////////////////////////////////// | 3333 //////////////////////////////////////////////////////////////////////////////// |
2741 // blending_interface: | 3334 // blending_interface: |
2742 | 3335 |
2743 // Implements the blending interface to a Surface. The "blend mode" and | 3336 // Implements the blending interface to a Surface. The "blend mode" and |
2744 // "alpha"-state is set to SrcOver and 1 upon destruction. A window property | 3337 // "alpha"-state is set to SrcOver and 1 upon destruction. A window property |
2745 // will be set during the lifetime of this class to prevent multiple instances | 3338 // will be set during the lifetime of this class to prevent multiple instances |
2746 // from being created for the same Surface. | 3339 // from being created for the same Surface. |
2747 class Blending : public SurfaceObserver { | 3340 class Blending : public SurfaceObserver { |
2748 public: | 3341 public: |
2749 explicit Blending(Surface* surface) : surface_(surface) { | 3342 explicit Blending(Surface* surface) : surface_(surface) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2782 }; | 3375 }; |
2783 | 3376 |
2784 void blending_destroy(wl_client* client, wl_resource* resource) { | 3377 void blending_destroy(wl_client* client, wl_resource* resource) { |
2785 wl_resource_destroy(resource); | 3378 wl_resource_destroy(resource); |
2786 } | 3379 } |
2787 | 3380 |
2788 void blending_set_blending(wl_client* client, | 3381 void blending_set_blending(wl_client* client, |
2789 wl_resource* resource, | 3382 wl_resource* resource, |
2790 uint32_t equation) { | 3383 uint32_t equation) { |
2791 switch (equation) { | 3384 switch (equation) { |
2792 case ZWP_BLENDING_V1_BLENDING_EQUATION_NONE: | 3385 case ZCR_BLENDING_V1_BLENDING_EQUATION_NONE: |
2793 GetUserDataAs<Blending>(resource)->SetBlendMode(SkXfermode::kSrc_Mode); | 3386 GetUserDataAs<Blending>(resource)->SetBlendMode(SkXfermode::kSrc_Mode); |
2794 break; | 3387 break; |
2795 case ZWP_BLENDING_V1_BLENDING_EQUATION_PREMULT: | 3388 case ZCR_BLENDING_V1_BLENDING_EQUATION_PREMULT: |
2796 GetUserDataAs<Blending>(resource)->SetBlendMode( | 3389 GetUserDataAs<Blending>(resource)->SetBlendMode( |
2797 SkXfermode::kSrcOver_Mode); | 3390 SkXfermode::kSrcOver_Mode); |
2798 break; | 3391 break; |
2799 case ZWP_BLENDING_V1_BLENDING_EQUATION_COVERAGE: | 3392 case ZCR_BLENDING_V1_BLENDING_EQUATION_COVERAGE: |
2800 NOTIMPLEMENTED(); | 3393 NOTIMPLEMENTED(); |
2801 break; | 3394 break; |
2802 default: | 3395 default: |
2803 DLOG(WARNING) << "Unsupported blending equation: " << equation; | 3396 DLOG(WARNING) << "Unsupported blending equation: " << equation; |
2804 break; | 3397 break; |
2805 } | 3398 } |
2806 } | 3399 } |
2807 | 3400 |
2808 void blending_set_alpha(wl_client* client, | 3401 void blending_set_alpha(wl_client* client, |
2809 wl_resource* resource, | 3402 wl_resource* resource, |
2810 wl_fixed_t alpha) { | 3403 wl_fixed_t alpha) { |
2811 GetUserDataAs<Blending>(resource)->SetAlpha(wl_fixed_to_double(alpha)); | 3404 GetUserDataAs<Blending>(resource)->SetAlpha(wl_fixed_to_double(alpha)); |
2812 } | 3405 } |
2813 | 3406 |
2814 const struct zwp_blending_v1_interface blending_implementation = { | 3407 const struct zcr_blending_v1_interface blending_implementation = { |
2815 blending_destroy, blending_set_blending, blending_set_alpha}; | 3408 blending_destroy, blending_set_blending, blending_set_alpha}; |
2816 | 3409 |
| 3410 void blending_destroy_DEPRECATED(wl_client* client, wl_resource* resource) { |
| 3411 wl_resource_destroy(resource); |
| 3412 } |
| 3413 |
| 3414 void blending_set_blending_DEPRECATED(wl_client* client, |
| 3415 wl_resource* resource, |
| 3416 uint32_t equation) { |
| 3417 switch (equation) { |
| 3418 case ZWP_BLENDING_V1_BLENDING_EQUATION_NONE: |
| 3419 GetUserDataAs<Blending>(resource)->SetBlendMode(SkXfermode::kSrc_Mode); |
| 3420 break; |
| 3421 case ZWP_BLENDING_V1_BLENDING_EQUATION_PREMULT: |
| 3422 GetUserDataAs<Blending>(resource)->SetBlendMode( |
| 3423 SkXfermode::kSrcOver_Mode); |
| 3424 break; |
| 3425 case ZWP_BLENDING_V1_BLENDING_EQUATION_COVERAGE: |
| 3426 NOTIMPLEMENTED(); |
| 3427 break; |
| 3428 default: |
| 3429 DLOG(WARNING) << "Unsupported blending equation: " << equation; |
| 3430 break; |
| 3431 } |
| 3432 } |
| 3433 |
| 3434 void blending_set_alpha_DEPRECATED(wl_client* client, |
| 3435 wl_resource* resource, |
| 3436 wl_fixed_t alpha) { |
| 3437 GetUserDataAs<Blending>(resource)->SetAlpha(wl_fixed_to_double(alpha)); |
| 3438 } |
| 3439 |
| 3440 const struct zwp_blending_v1_interface blending_implementation_DEPRECATED = { |
| 3441 blending_destroy_DEPRECATED, blending_set_blending_DEPRECATED, |
| 3442 blending_set_alpha_DEPRECATED}; |
| 3443 |
2817 //////////////////////////////////////////////////////////////////////////////// | 3444 //////////////////////////////////////////////////////////////////////////////// |
2818 // alpha_compositing_interface: | 3445 // alpha_compositing_interface: |
2819 | 3446 |
2820 void alpha_compositing_destroy(wl_client* client, wl_resource* resource) { | 3447 void alpha_compositing_destroy(wl_client* client, wl_resource* resource) { |
2821 wl_resource_destroy(resource); | 3448 wl_resource_destroy(resource); |
2822 } | 3449 } |
2823 | 3450 |
2824 void alpha_compositing_get_blending(wl_client* client, | 3451 void alpha_compositing_get_blending(wl_client* client, |
2825 wl_resource* resource, | 3452 wl_resource* resource, |
2826 uint32_t id, | 3453 uint32_t id, |
2827 wl_resource* surface_resource) { | 3454 wl_resource* surface_resource) { |
2828 Surface* surface = GetUserDataAs<Surface>(surface_resource); | 3455 Surface* surface = GetUserDataAs<Surface>(surface_resource); |
2829 if (surface->GetProperty(kSurfaceHasBlendingKey)) { | 3456 if (surface->GetProperty(kSurfaceHasBlendingKey)) { |
2830 wl_resource_post_error(resource, | 3457 wl_resource_post_error(resource, |
2831 ZWP_ALPHA_COMPOSITING_V1_ERROR_BLENDING_EXISTS, | 3458 ZCR_ALPHA_COMPOSITING_V1_ERROR_BLENDING_EXISTS, |
2832 "a blending object for that surface already exists"); | 3459 "a blending object for that surface already exists"); |
2833 return; | 3460 return; |
2834 } | 3461 } |
2835 | 3462 |
2836 wl_resource* blending_resource = | 3463 wl_resource* blending_resource = |
2837 wl_resource_create(client, &zwp_blending_v1_interface, 1, id); | 3464 wl_resource_create(client, &zcr_blending_v1_interface, 1, id); |
2838 | 3465 |
2839 SetImplementation(blending_resource, &blending_implementation, | 3466 SetImplementation(blending_resource, &blending_implementation, |
2840 base::MakeUnique<Blending>(surface)); | 3467 base::MakeUnique<Blending>(surface)); |
2841 } | 3468 } |
2842 | 3469 |
2843 const struct zwp_alpha_compositing_v1_interface | 3470 const struct zcr_alpha_compositing_v1_interface |
2844 alpha_compositing_implementation = {alpha_compositing_destroy, | 3471 alpha_compositing_implementation = {alpha_compositing_destroy, |
2845 alpha_compositing_get_blending}; | 3472 alpha_compositing_get_blending}; |
2846 | 3473 |
2847 void bind_alpha_compositing(wl_client* client, | 3474 void bind_alpha_compositing(wl_client* client, |
2848 void* data, | 3475 void* data, |
2849 uint32_t version, | 3476 uint32_t version, |
2850 uint32_t id) { | 3477 uint32_t id) { |
2851 wl_resource* resource = | 3478 wl_resource* resource = |
2852 wl_resource_create(client, &zwp_alpha_compositing_v1_interface, 1, id); | 3479 wl_resource_create(client, &zcr_alpha_compositing_v1_interface, 1, id); |
2853 | 3480 |
2854 wl_resource_set_implementation(resource, &alpha_compositing_implementation, | 3481 wl_resource_set_implementation(resource, &alpha_compositing_implementation, |
2855 data, nullptr); | 3482 data, nullptr); |
2856 } | 3483 } |
2857 | 3484 |
| 3485 void alpha_compositing_destroy_DEPRECATED(wl_client* client, |
| 3486 wl_resource* resource) { |
| 3487 wl_resource_destroy(resource); |
| 3488 } |
| 3489 |
| 3490 void alpha_compositing_get_blending_DEPRECATED(wl_client* client, |
| 3491 wl_resource* resource, |
| 3492 uint32_t id, |
| 3493 wl_resource* surface_resource) { |
| 3494 Surface* surface = GetUserDataAs<Surface>(surface_resource); |
| 3495 if (surface->GetProperty(kSurfaceHasBlendingKey)) { |
| 3496 wl_resource_post_error(resource, |
| 3497 ZWP_ALPHA_COMPOSITING_V1_ERROR_BLENDING_EXISTS, |
| 3498 "a blending object for that surface already exists"); |
| 3499 return; |
| 3500 } |
| 3501 |
| 3502 wl_resource* blending_resource = |
| 3503 wl_resource_create(client, &zwp_blending_v1_interface, 1, id); |
| 3504 |
| 3505 SetImplementation(blending_resource, &blending_implementation_DEPRECATED, |
| 3506 base::MakeUnique<Blending>(surface)); |
| 3507 } |
| 3508 |
| 3509 const struct zwp_alpha_compositing_v1_interface |
| 3510 alpha_compositing_implementation_DEPRECATED = { |
| 3511 alpha_compositing_destroy_DEPRECATED, |
| 3512 alpha_compositing_get_blending_DEPRECATED}; |
| 3513 |
| 3514 void bind_alpha_compositing_DEPRECATED(wl_client* client, |
| 3515 void* data, |
| 3516 uint32_t version, |
| 3517 uint32_t id) { |
| 3518 wl_resource* resource = |
| 3519 wl_resource_create(client, &zwp_alpha_compositing_v1_interface, 1, id); |
| 3520 |
| 3521 wl_resource_set_implementation( |
| 3522 resource, &alpha_compositing_implementation_DEPRECATED, data, nullptr); |
| 3523 } |
| 3524 |
2858 //////////////////////////////////////////////////////////////////////////////// | 3525 //////////////////////////////////////////////////////////////////////////////// |
2859 // gaming_input_interface: | 3526 // gaming_input_interface: |
2860 | 3527 |
2861 // Gamepad delegate class that forwards gamepad events to the client resource. | 3528 // Gamepad delegate class that forwards gamepad events to the client resource. |
2862 class WaylandGamepadDelegate : public GamepadDelegate { | 3529 class WaylandGamepadDelegate : public GamepadDelegate { |
2863 public: | 3530 public: |
2864 explicit WaylandGamepadDelegate(wl_resource* gamepad_resource) | 3531 explicit WaylandGamepadDelegate(wl_resource* gamepad_resource) |
2865 : gamepad_resource_(gamepad_resource) {} | 3532 : gamepad_resource_(gamepad_resource) {} |
2866 | 3533 |
2867 // Overridden from GamepadDelegate: | 3534 // Overridden from GamepadDelegate: |
2868 void OnGamepadDestroying(Gamepad* gamepad) override { delete this; } | 3535 void OnGamepadDestroying(Gamepad* gamepad) override { delete this; } |
2869 bool CanAcceptGamepadEventsForSurface(Surface* surface) const override { | 3536 bool CanAcceptGamepadEventsForSurface(Surface* surface) const override { |
2870 wl_resource* surface_resource = GetSurfaceResource(surface); | 3537 wl_resource* surface_resource = GetSurfaceResource(surface); |
2871 return surface_resource && | 3538 return surface_resource && |
2872 wl_resource_get_client(surface_resource) == client(); | 3539 wl_resource_get_client(surface_resource) == client(); |
2873 } | 3540 } |
2874 void OnStateChange(bool connected) override { | 3541 void OnStateChange(bool connected) override { |
2875 uint32_t status = connected ? ZWP_GAMEPAD_V1_GAMEPAD_STATE_ON | 3542 uint32_t status = connected ? ZCR_GAMEPAD_V1_GAMEPAD_STATE_ON |
2876 : ZWP_GAMEPAD_V1_GAMEPAD_STATE_OFF; | 3543 : ZCR_GAMEPAD_V1_GAMEPAD_STATE_OFF; |
2877 zwp_gamepad_v1_send_state_change(gamepad_resource_, status); | 3544 zcr_gamepad_v1_send_state_change(gamepad_resource_, status); |
2878 wl_client_flush(client()); | 3545 wl_client_flush(client()); |
2879 } | 3546 } |
2880 void OnAxis(int axis, double value) override { | 3547 void OnAxis(int axis, double value) override { |
2881 zwp_gamepad_v1_send_axis(gamepad_resource_, NowInMilliseconds(), axis, | 3548 zcr_gamepad_v1_send_axis(gamepad_resource_, NowInMilliseconds(), axis, |
2882 wl_fixed_from_double(value)); | 3549 wl_fixed_from_double(value)); |
2883 } | 3550 } |
2884 void OnButton(int button, bool pressed, double value) override { | 3551 void OnButton(int button, bool pressed, double value) override { |
2885 uint32_t state = pressed ? ZWP_GAMEPAD_V1_BUTTON_STATE_PRESSED | 3552 uint32_t state = pressed ? ZCR_GAMEPAD_V1_BUTTON_STATE_PRESSED |
2886 : ZWP_GAMEPAD_V1_BUTTON_STATE_RELEASED; | 3553 : ZCR_GAMEPAD_V1_BUTTON_STATE_RELEASED; |
2887 zwp_gamepad_v1_send_button(gamepad_resource_, NowInMilliseconds(), button, | 3554 zcr_gamepad_v1_send_button(gamepad_resource_, NowInMilliseconds(), button, |
2888 state, wl_fixed_from_double(value)); | 3555 state, wl_fixed_from_double(value)); |
2889 } | 3556 } |
2890 void OnFrame() override { | 3557 void OnFrame() override { |
2891 zwp_gamepad_v1_send_frame(gamepad_resource_, NowInMilliseconds()); | 3558 zcr_gamepad_v1_send_frame(gamepad_resource_, NowInMilliseconds()); |
2892 wl_client_flush(client()); | 3559 wl_client_flush(client()); |
2893 } | 3560 } |
2894 | 3561 |
2895 private: | 3562 private: |
2896 // The client who own this gamepad instance. | 3563 // The client who own this gamepad instance. |
2897 wl_client* client() const { | 3564 wl_client* client() const { |
2898 return wl_resource_get_client(gamepad_resource_); | 3565 return wl_resource_get_client(gamepad_resource_); |
2899 } | 3566 } |
2900 | 3567 |
2901 // The gamepad resource associated with the gamepad. | 3568 // The gamepad resource associated with the gamepad. |
2902 wl_resource* const gamepad_resource_; | 3569 wl_resource* const gamepad_resource_; |
2903 | 3570 |
2904 DISALLOW_COPY_AND_ASSIGN(WaylandGamepadDelegate); | 3571 DISALLOW_COPY_AND_ASSIGN(WaylandGamepadDelegate); |
2905 }; | 3572 }; |
2906 | 3573 |
2907 void gamepad_destroy(wl_client* client, wl_resource* resource) { | 3574 void gamepad_destroy(wl_client* client, wl_resource* resource) { |
2908 wl_resource_destroy(resource); | 3575 wl_resource_destroy(resource); |
2909 } | 3576 } |
2910 | 3577 |
2911 const struct zwp_gamepad_v1_interface gamepad_implementation = { | 3578 const struct zcr_gamepad_v1_interface gamepad_implementation = { |
2912 gamepad_destroy}; | 3579 gamepad_destroy}; |
2913 | 3580 |
2914 void gaming_input_get_gamepad(wl_client* client, | 3581 void gaming_input_get_gamepad(wl_client* client, |
2915 wl_resource* resource, | 3582 wl_resource* resource, |
2916 uint32_t id, | 3583 uint32_t id, |
2917 wl_resource* seat) { | 3584 wl_resource* seat) { |
2918 wl_resource* gamepad_resource = wl_resource_create( | 3585 wl_resource* gamepad_resource = wl_resource_create( |
2919 client, &zwp_gamepad_v1_interface, wl_resource_get_version(resource), id); | 3586 client, &zcr_gamepad_v1_interface, wl_resource_get_version(resource), id); |
2920 | 3587 |
2921 base::Thread* gaming_input_thread = GetUserDataAs<base::Thread>(resource); | 3588 base::Thread* gaming_input_thread = GetUserDataAs<base::Thread>(resource); |
2922 | 3589 |
2923 SetImplementation( | 3590 SetImplementation( |
2924 gamepad_resource, &gamepad_implementation, | 3591 gamepad_resource, &gamepad_implementation, |
2925 base::MakeUnique<Gamepad>(new WaylandGamepadDelegate(gamepad_resource), | 3592 base::MakeUnique<Gamepad>(new WaylandGamepadDelegate(gamepad_resource), |
2926 gaming_input_thread->task_runner().get())); | 3593 gaming_input_thread->task_runner().get())); |
2927 } | 3594 } |
2928 | 3595 |
2929 const struct zwp_gaming_input_v1_interface gaming_input_implementation = { | 3596 const struct zcr_gaming_input_v1_interface gaming_input_implementation = { |
2930 gaming_input_get_gamepad}; | 3597 gaming_input_get_gamepad}; |
2931 | 3598 |
2932 void bind_gaming_input(wl_client* client, | 3599 void bind_gaming_input(wl_client* client, |
2933 void* data, | 3600 void* data, |
2934 uint32_t version, | 3601 uint32_t version, |
2935 uint32_t id) { | 3602 uint32_t id) { |
2936 wl_resource* resource = | 3603 wl_resource* resource = |
2937 wl_resource_create(client, &zwp_gaming_input_v1_interface, version, id); | 3604 wl_resource_create(client, &zcr_gaming_input_v1_interface, version, id); |
2938 | 3605 |
2939 std::unique_ptr<base::Thread> gaming_input_thread( | 3606 std::unique_ptr<base::Thread> gaming_input_thread( |
2940 new base::Thread("Exo gaming input polling thread.")); | 3607 new base::Thread("Exo gaming input polling thread.")); |
2941 gaming_input_thread->StartWithOptions( | 3608 gaming_input_thread->StartWithOptions( |
2942 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 3609 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
2943 | 3610 |
2944 SetImplementation(resource, &gaming_input_implementation, | 3611 SetImplementation(resource, &gaming_input_implementation, |
2945 std::move(gaming_input_thread)); | 3612 std::move(gaming_input_thread)); |
2946 } | 3613 } |
2947 | 3614 |
| 3615 // Gamepad delegate class that forwards gamepad events to the client resource. |
| 3616 class WaylandGamepadDelegate_DEPRECATED : public GamepadDelegate { |
| 3617 public: |
| 3618 explicit WaylandGamepadDelegate_DEPRECATED(wl_resource* gamepad_resource) |
| 3619 : gamepad_resource_(gamepad_resource) {} |
| 3620 |
| 3621 // Overridden from GamepadDelegate: |
| 3622 void OnGamepadDestroying(Gamepad* gamepad) override { delete this; } |
| 3623 bool CanAcceptGamepadEventsForSurface(Surface* surface) const override { |
| 3624 wl_resource* surface_resource = GetSurfaceResource(surface); |
| 3625 return surface_resource && |
| 3626 wl_resource_get_client(surface_resource) == client(); |
| 3627 } |
| 3628 void OnStateChange(bool connected) override { |
| 3629 uint32_t status = connected ? ZWP_GAMEPAD_V1_GAMEPAD_STATE_ON |
| 3630 : ZWP_GAMEPAD_V1_GAMEPAD_STATE_OFF; |
| 3631 zwp_gamepad_v1_send_state_change(gamepad_resource_, status); |
| 3632 wl_client_flush(client()); |
| 3633 } |
| 3634 void OnAxis(int axis, double value) override { |
| 3635 zwp_gamepad_v1_send_axis(gamepad_resource_, NowInMilliseconds(), axis, |
| 3636 wl_fixed_from_double(value)); |
| 3637 } |
| 3638 void OnButton(int button, bool pressed, double value) override { |
| 3639 uint32_t state = pressed ? ZWP_GAMEPAD_V1_BUTTON_STATE_PRESSED |
| 3640 : ZWP_GAMEPAD_V1_BUTTON_STATE_RELEASED; |
| 3641 zwp_gamepad_v1_send_button(gamepad_resource_, NowInMilliseconds(), button, |
| 3642 state, wl_fixed_from_double(value)); |
| 3643 } |
| 3644 void OnFrame() override { |
| 3645 zwp_gamepad_v1_send_frame(gamepad_resource_, NowInMilliseconds()); |
| 3646 wl_client_flush(client()); |
| 3647 } |
| 3648 |
| 3649 private: |
| 3650 // The client who own this gamepad instance. |
| 3651 wl_client* client() const { |
| 3652 return wl_resource_get_client(gamepad_resource_); |
| 3653 } |
| 3654 |
| 3655 // The gamepad resource associated with the gamepad. |
| 3656 wl_resource* const gamepad_resource_; |
| 3657 |
| 3658 DISALLOW_COPY_AND_ASSIGN(WaylandGamepadDelegate_DEPRECATED); |
| 3659 }; |
| 3660 |
| 3661 void gamepad_destroy_DEPRECATED(wl_client* client, wl_resource* resource) { |
| 3662 wl_resource_destroy(resource); |
| 3663 } |
| 3664 |
| 3665 const struct zwp_gamepad_v1_interface gamepad_implementation_DEPRECATED = { |
| 3666 gamepad_destroy_DEPRECATED}; |
| 3667 |
| 3668 void gaming_input_get_gamepad_DEPRECATED(wl_client* client, |
| 3669 wl_resource* resource, |
| 3670 uint32_t id, |
| 3671 wl_resource* seat) { |
| 3672 wl_resource* gamepad_resource = wl_resource_create( |
| 3673 client, &zwp_gamepad_v1_interface, wl_resource_get_version(resource), id); |
| 3674 |
| 3675 base::Thread* gaming_input_thread = GetUserDataAs<base::Thread>(resource); |
| 3676 |
| 3677 SetImplementation(gamepad_resource, &gamepad_implementation_DEPRECATED, |
| 3678 base::MakeUnique<Gamepad>( |
| 3679 new WaylandGamepadDelegate_DEPRECATED(gamepad_resource), |
| 3680 gaming_input_thread->task_runner().get())); |
| 3681 } |
| 3682 |
| 3683 const struct zwp_gaming_input_v1_interface |
| 3684 gaming_input_implementation_DEPRECATED = { |
| 3685 gaming_input_get_gamepad_DEPRECATED}; |
| 3686 |
| 3687 void bind_gaming_input_DEPRECATED(wl_client* client, |
| 3688 void* data, |
| 3689 uint32_t version, |
| 3690 uint32_t id) { |
| 3691 wl_resource* resource = |
| 3692 wl_resource_create(client, &zwp_gaming_input_v1_interface, version, id); |
| 3693 |
| 3694 std::unique_ptr<base::Thread> gaming_input_thread( |
| 3695 new base::Thread("Exo gaming input polling thread.")); |
| 3696 gaming_input_thread->StartWithOptions( |
| 3697 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| 3698 |
| 3699 SetImplementation(resource, &gaming_input_implementation_DEPRECATED, |
| 3700 std::move(gaming_input_thread)); |
| 3701 } |
| 3702 |
2948 //////////////////////////////////////////////////////////////////////////////// | 3703 //////////////////////////////////////////////////////////////////////////////// |
2949 // pointer_stylus interface: | 3704 // pointer_stylus interface: |
2950 | 3705 |
2951 class WaylandPointerStylusDelegate : public PointerStylusDelegate { | 3706 class WaylandPointerStylusDelegate : public PointerStylusDelegate { |
2952 public: | 3707 public: |
2953 WaylandPointerStylusDelegate(wl_resource* resource, Pointer* pointer) | 3708 WaylandPointerStylusDelegate(wl_resource* resource, Pointer* pointer) |
2954 : resource_(resource), pointer_(pointer) { | 3709 : resource_(resource), pointer_(pointer) { |
2955 pointer_->SetStylusDelegate(this); | 3710 pointer_->SetStylusDelegate(this); |
2956 } | 3711 } |
2957 ~WaylandPointerStylusDelegate() override { | 3712 ~WaylandPointerStylusDelegate() override { |
2958 if (pointer_ != nullptr) | 3713 if (pointer_ != nullptr) |
2959 pointer_->SetStylusDelegate(nullptr); | 3714 pointer_->SetStylusDelegate(nullptr); |
2960 } | 3715 } |
2961 void OnPointerDestroying(Pointer* pointer) override { pointer_ = nullptr; } | 3716 void OnPointerDestroying(Pointer* pointer) override { pointer_ = nullptr; } |
2962 void OnPointerToolChange(ui::EventPointerType type) override { | 3717 void OnPointerToolChange(ui::EventPointerType type) override { |
| 3718 uint wayland_type = ZCR_POINTER_STYLUS_V1_TOOL_TYPE_MOUSE; |
| 3719 if (type == ui::EventPointerType::POINTER_TYPE_PEN) |
| 3720 wayland_type = ZCR_POINTER_STYLUS_V1_TOOL_TYPE_PEN; |
| 3721 else if (type == ui::EventPointerType::POINTER_TYPE_ERASER) |
| 3722 wayland_type = ZCR_POINTER_STYLUS_V1_TOOL_TYPE_ERASER; |
| 3723 zcr_pointer_stylus_v1_send_tool_change(resource_, wayland_type); |
| 3724 } |
| 3725 void OnPointerForce(base::TimeTicks time_stamp, float force) override { |
| 3726 zcr_pointer_stylus_v1_send_force(resource_, |
| 3727 TimeTicksToMilliseconds(time_stamp), |
| 3728 wl_fixed_from_double(force)); |
| 3729 } |
| 3730 void OnPointerTilt(base::TimeTicks time_stamp, gfx::Vector2dF tilt) override { |
| 3731 zcr_pointer_stylus_v1_send_tilt( |
| 3732 resource_, TimeTicksToMilliseconds(time_stamp), |
| 3733 wl_fixed_from_double(tilt.x()), wl_fixed_from_double(tilt.y())); |
| 3734 } |
| 3735 |
| 3736 private: |
| 3737 wl_resource* resource_; |
| 3738 Pointer* pointer_; |
| 3739 |
| 3740 // The client who own this pointer stylus instance. |
| 3741 wl_client* client() const { return wl_resource_get_client(resource_); } |
| 3742 |
| 3743 DISALLOW_COPY_AND_ASSIGN(WaylandPointerStylusDelegate); |
| 3744 }; |
| 3745 |
| 3746 void pointer_stylus_destroy(wl_client* client, wl_resource* resource) { |
| 3747 wl_resource_destroy(resource); |
| 3748 } |
| 3749 |
| 3750 const struct zcr_pointer_stylus_v1_interface pointer_stylus_implementation = { |
| 3751 pointer_stylus_destroy}; |
| 3752 |
| 3753 class WaylandPointerStylusDelegate_DEPRECATED : public PointerStylusDelegate { |
| 3754 public: |
| 3755 WaylandPointerStylusDelegate_DEPRECATED(wl_resource* resource, |
| 3756 Pointer* pointer) |
| 3757 : resource_(resource), pointer_(pointer) { |
| 3758 pointer_->SetStylusDelegate(this); |
| 3759 } |
| 3760 ~WaylandPointerStylusDelegate_DEPRECATED() override { |
| 3761 if (pointer_ != nullptr) |
| 3762 pointer_->SetStylusDelegate(nullptr); |
| 3763 } |
| 3764 void OnPointerDestroying(Pointer* pointer) override { pointer_ = nullptr; } |
| 3765 void OnPointerToolChange(ui::EventPointerType type) override { |
2963 uint wayland_type = ZWP_POINTER_STYLUS_V1_TOOL_TYPE_MOUSE; | 3766 uint wayland_type = ZWP_POINTER_STYLUS_V1_TOOL_TYPE_MOUSE; |
2964 if (type == ui::EventPointerType::POINTER_TYPE_PEN) | 3767 if (type == ui::EventPointerType::POINTER_TYPE_PEN) |
2965 wayland_type = ZWP_POINTER_STYLUS_V1_TOOL_TYPE_PEN; | 3768 wayland_type = ZWP_POINTER_STYLUS_V1_TOOL_TYPE_PEN; |
2966 else if (type == ui::EventPointerType::POINTER_TYPE_ERASER) | 3769 else if (type == ui::EventPointerType::POINTER_TYPE_ERASER) |
2967 wayland_type = ZWP_POINTER_STYLUS_V1_TOOL_TYPE_ERASER; | 3770 wayland_type = ZWP_POINTER_STYLUS_V1_TOOL_TYPE_ERASER; |
2968 zwp_pointer_stylus_v1_send_tool_change(resource_, wayland_type); | 3771 zwp_pointer_stylus_v1_send_tool_change(resource_, wayland_type); |
2969 } | 3772 } |
2970 void OnPointerForce(base::TimeTicks time_stamp, float force) override { | 3773 void OnPointerForce(base::TimeTicks time_stamp, float force) override { |
2971 zwp_pointer_stylus_v1_send_force(resource_, | 3774 zwp_pointer_stylus_v1_send_force(resource_, |
2972 TimeTicksToMilliseconds(time_stamp), | 3775 TimeTicksToMilliseconds(time_stamp), |
2973 wl_fixed_from_double(force)); | 3776 wl_fixed_from_double(force)); |
2974 } | 3777 } |
2975 void OnPointerTilt(base::TimeTicks time_stamp, gfx::Vector2dF tilt) override { | 3778 void OnPointerTilt(base::TimeTicks time_stamp, gfx::Vector2dF tilt) override { |
2976 zwp_pointer_stylus_v1_send_tilt( | 3779 zwp_pointer_stylus_v1_send_tilt( |
2977 resource_, TimeTicksToMilliseconds(time_stamp), | 3780 resource_, TimeTicksToMilliseconds(time_stamp), |
2978 wl_fixed_from_double(tilt.x()), wl_fixed_from_double(tilt.y())); | 3781 wl_fixed_from_double(tilt.x()), wl_fixed_from_double(tilt.y())); |
2979 } | 3782 } |
2980 | 3783 |
2981 private: | 3784 private: |
2982 wl_resource* resource_; | 3785 wl_resource* resource_; |
2983 Pointer* pointer_; | 3786 Pointer* pointer_; |
2984 | 3787 |
2985 // The client who own this pointer stylus instance. | 3788 // The client who own this pointer stylus instance. |
2986 wl_client* client() const { return wl_resource_get_client(resource_); } | 3789 wl_client* client() const { return wl_resource_get_client(resource_); } |
2987 | 3790 |
2988 DISALLOW_COPY_AND_ASSIGN(WaylandPointerStylusDelegate); | 3791 DISALLOW_COPY_AND_ASSIGN(WaylandPointerStylusDelegate_DEPRECATED); |
2989 }; | 3792 }; |
2990 | 3793 |
2991 void pointer_stylus_destroy(wl_client* client, wl_resource* resource) { | 3794 void pointer_stylus_destroy_DEPRECATED(wl_client* client, |
| 3795 wl_resource* resource) { |
2992 wl_resource_destroy(resource); | 3796 wl_resource_destroy(resource); |
2993 } | 3797 } |
2994 | 3798 |
2995 const struct zwp_pointer_stylus_v1_interface pointer_stylus_implementation = { | 3799 const struct zwp_pointer_stylus_v1_interface |
2996 pointer_stylus_destroy}; | 3800 pointer_stylus_implementation_DEPRECATED = { |
| 3801 pointer_stylus_destroy_DEPRECATED}; |
2997 | 3802 |
2998 //////////////////////////////////////////////////////////////////////////////// | 3803 //////////////////////////////////////////////////////////////////////////////// |
2999 // stylus interface: | 3804 // stylus interface: |
3000 | 3805 |
3001 void stylus_get_pointer_stylus(wl_client* client, | 3806 void stylus_get_pointer_stylus(wl_client* client, |
3002 wl_resource* resource, | 3807 wl_resource* resource, |
3003 uint32_t id, | 3808 uint32_t id, |
3004 wl_resource* pointer_resource) { | 3809 wl_resource* pointer_resource) { |
3005 Pointer* pointer = GetUserDataAs<Pointer>(pointer_resource); | 3810 Pointer* pointer = GetUserDataAs<Pointer>(pointer_resource); |
3006 | 3811 |
3007 wl_resource* stylus_resource = | 3812 wl_resource* stylus_resource = |
3008 wl_resource_create(client, &zwp_pointer_stylus_v1_interface, 1, id); | 3813 wl_resource_create(client, &zcr_pointer_stylus_v1_interface, 1, id); |
3009 | 3814 |
3010 SetImplementation( | 3815 SetImplementation( |
3011 stylus_resource, &pointer_stylus_implementation, | 3816 stylus_resource, &pointer_stylus_implementation, |
3012 base::MakeUnique<WaylandPointerStylusDelegate>(stylus_resource, pointer)); | 3817 base::MakeUnique<WaylandPointerStylusDelegate>(stylus_resource, pointer)); |
3013 } | 3818 } |
3014 | 3819 |
3015 const struct zwp_stylus_v1_interface stylus_implementation = { | 3820 const struct zcr_stylus_v1_interface stylus_implementation = { |
3016 stylus_get_pointer_stylus}; | 3821 stylus_get_pointer_stylus}; |
3017 | 3822 |
3018 void bind_stylus(wl_client* client, void* data, uint32_t version, uint32_t id) { | 3823 void bind_stylus(wl_client* client, void* data, uint32_t version, uint32_t id) { |
3019 wl_resource* resource = | 3824 wl_resource* resource = |
3020 wl_resource_create(client, &zwp_stylus_v1_interface, version, id); | 3825 wl_resource_create(client, &zcr_stylus_v1_interface, version, id); |
3021 wl_resource_set_implementation(resource, &stylus_implementation, data, | 3826 wl_resource_set_implementation(resource, &stylus_implementation, data, |
3022 nullptr); | 3827 nullptr); |
3023 } | 3828 } |
3024 | 3829 |
| 3830 void stylus_get_pointer_stylus_DEPRECATED(wl_client* client, |
| 3831 wl_resource* resource, |
| 3832 uint32_t id, |
| 3833 wl_resource* pointer_resource) { |
| 3834 Pointer* pointer = GetUserDataAs<Pointer>(pointer_resource); |
| 3835 |
| 3836 wl_resource* stylus_resource = |
| 3837 wl_resource_create(client, &zwp_pointer_stylus_v1_interface, 1, id); |
| 3838 |
| 3839 SetImplementation(stylus_resource, &pointer_stylus_implementation_DEPRECATED, |
| 3840 base::MakeUnique<WaylandPointerStylusDelegate_DEPRECATED>( |
| 3841 stylus_resource, pointer)); |
| 3842 } |
| 3843 |
| 3844 const struct zwp_stylus_v1_interface stylus_implementation_DEPRECATED = { |
| 3845 stylus_get_pointer_stylus_DEPRECATED}; |
| 3846 |
| 3847 void bind_stylus_DEPRECATED(wl_client* client, |
| 3848 void* data, |
| 3849 uint32_t version, |
| 3850 uint32_t id) { |
| 3851 wl_resource* resource = |
| 3852 wl_resource_create(client, &zwp_stylus_v1_interface, version, id); |
| 3853 wl_resource_set_implementation(resource, &stylus_implementation_DEPRECATED, |
| 3854 data, nullptr); |
| 3855 } |
| 3856 |
3025 } // namespace | 3857 } // namespace |
3026 | 3858 |
3027 //////////////////////////////////////////////////////////////////////////////// | 3859 //////////////////////////////////////////////////////////////////////////////// |
3028 // Server, public: | 3860 // Server, public: |
3029 | 3861 |
3030 Server::Server(Display* display) | 3862 Server::Server(Display* display) |
3031 : display_(display), wl_display_(wl_display_create()) { | 3863 : display_(display), wl_display_(wl_display_create()) { |
3032 wl_global_create(wl_display_.get(), &wl_compositor_interface, | 3864 wl_global_create(wl_display_.get(), &wl_compositor_interface, |
3033 compositor_version, display_, bind_compositor); | 3865 compositor_version, display_, bind_compositor); |
3034 wl_global_create(wl_display_.get(), &wl_shm_interface, 1, display_, bind_shm); | 3866 wl_global_create(wl_display_.get(), &wl_shm_interface, 1, display_, bind_shm); |
3035 #if defined(USE_OZONE) | 3867 #if defined(USE_OZONE) |
3036 wl_global_create(wl_display_.get(), &wl_drm_interface, drm_version, display_, | 3868 wl_global_create(wl_display_.get(), &wl_drm_interface, drm_version, display_, |
3037 bind_drm); | 3869 bind_drm); |
3038 wl_global_create(wl_display_.get(), &zwp_linux_dmabuf_v1_interface, 1, | 3870 wl_global_create(wl_display_.get(), &zwp_linux_dmabuf_v1_interface, 1, |
3039 display_, bind_linux_dmabuf); | 3871 display_, bind_linux_dmabuf); |
3040 #endif | 3872 #endif |
3041 wl_global_create(wl_display_.get(), &wl_subcompositor_interface, 1, display_, | 3873 wl_global_create(wl_display_.get(), &wl_subcompositor_interface, 1, display_, |
3042 bind_subcompositor); | 3874 bind_subcompositor); |
3043 wl_global_create(wl_display_.get(), &wl_shell_interface, 1, display_, | 3875 wl_global_create(wl_display_.get(), &wl_shell_interface, 1, display_, |
3044 bind_shell); | 3876 bind_shell); |
3045 wl_global_create(wl_display_.get(), &wl_output_interface, output_version, | 3877 wl_global_create(wl_display_.get(), &wl_output_interface, output_version, |
3046 display_, bind_output); | 3878 display_, bind_output); |
3047 wl_global_create(wl_display_.get(), &xdg_shell_interface, 1, display_, | 3879 wl_global_create(wl_display_.get(), &xdg_shell_interface, 1, display_, |
3048 bind_xdg_shell); | 3880 bind_xdg_shell); |
| 3881 wl_global_create(wl_display_.get(), &zcr_vsync_feedback_v1_interface, 1, |
| 3882 display_, bind_vsync_feedback); |
3049 wl_global_create(wl_display_.get(), &zwp_vsync_feedback_v1_interface, 1, | 3883 wl_global_create(wl_display_.get(), &zwp_vsync_feedback_v1_interface, 1, |
3050 display_, bind_vsync_feedback); | 3884 display_, bind_vsync_feedback_DEPRECATED); |
3051 wl_global_create(wl_display_.get(), &wl_data_device_manager_interface, 1, | 3885 wl_global_create(wl_display_.get(), &wl_data_device_manager_interface, 1, |
3052 display_, bind_data_device_manager); | 3886 display_, bind_data_device_manager); |
3053 wl_global_create(wl_display_.get(), &wl_seat_interface, seat_version, | 3887 wl_global_create(wl_display_.get(), &wl_seat_interface, seat_version, |
3054 display_, bind_seat); | 3888 display_, bind_seat); |
3055 wl_global_create(wl_display_.get(), &wp_viewporter_interface, 1, display_, | 3889 wl_global_create(wl_display_.get(), &wp_viewporter_interface, 1, display_, |
3056 bind_viewporter); | 3890 bind_viewporter); |
| 3891 wl_global_create(wl_display_.get(), &zcr_secure_output_v1_interface, 1, |
| 3892 display_, bind_secure_output); |
3057 wl_global_create(wl_display_.get(), &zwp_secure_output_v1_interface, 1, | 3893 wl_global_create(wl_display_.get(), &zwp_secure_output_v1_interface, 1, |
3058 display_, bind_secure_output); | 3894 display_, bind_secure_output_DEPRECATED); |
| 3895 wl_global_create(wl_display_.get(), &zcr_alpha_compositing_v1_interface, 1, |
| 3896 display_, bind_alpha_compositing); |
3059 wl_global_create(wl_display_.get(), &zwp_alpha_compositing_v1_interface, 1, | 3897 wl_global_create(wl_display_.get(), &zwp_alpha_compositing_v1_interface, 1, |
3060 display_, bind_alpha_compositing); | 3898 display_, bind_alpha_compositing_DEPRECATED); |
| 3899 wl_global_create(wl_display_.get(), &zcr_remote_shell_v1_interface, |
| 3900 remote_shell_version, display_, bind_remote_shell); |
3061 wl_global_create(wl_display_.get(), &zwp_remote_shell_v1_interface, | 3901 wl_global_create(wl_display_.get(), &zwp_remote_shell_v1_interface, |
3062 remote_shell_version, display_, bind_remote_shell); | 3902 remote_shell_version, display_, |
| 3903 bind_remote_shell_DEPRECATED); |
| 3904 wl_global_create(wl_display_.get(), &zcr_gaming_input_v1_interface, 1, |
| 3905 display_, bind_gaming_input); |
3063 wl_global_create(wl_display_.get(), &zwp_gaming_input_v1_interface, 1, | 3906 wl_global_create(wl_display_.get(), &zwp_gaming_input_v1_interface, 1, |
3064 display_, bind_gaming_input); | 3907 display_, bind_gaming_input_DEPRECATED); |
| 3908 wl_global_create(wl_display_.get(), &zcr_stylus_v1_interface, 1, display_, |
| 3909 bind_stylus); |
3065 wl_global_create(wl_display_.get(), &zwp_stylus_v1_interface, 1, display_, | 3910 wl_global_create(wl_display_.get(), &zwp_stylus_v1_interface, 1, display_, |
3066 bind_stylus); | 3911 bind_stylus_DEPRECATED); |
3067 } | 3912 } |
3068 | 3913 |
3069 Server::~Server() {} | 3914 Server::~Server() {} |
3070 | 3915 |
3071 // static | 3916 // static |
3072 std::unique_ptr<Server> Server::Create(Display* display) { | 3917 std::unique_ptr<Server> Server::Create(Display* display) { |
3073 std::unique_ptr<Server> server(new Server(display)); | 3918 std::unique_ptr<Server> server(new Server(display)); |
3074 | 3919 |
3075 char* runtime_dir = getenv("XDG_RUNTIME_DIR"); | 3920 char* runtime_dir = getenv("XDG_RUNTIME_DIR"); |
3076 if (!runtime_dir) { | 3921 if (!runtime_dir) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3128 DCHECK(event_loop); | 3973 DCHECK(event_loop); |
3129 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); | 3974 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); |
3130 } | 3975 } |
3131 | 3976 |
3132 void Server::Flush() { | 3977 void Server::Flush() { |
3133 wl_display_flush_clients(wl_display_.get()); | 3978 wl_display_flush_clients(wl_display_.get()); |
3134 } | 3979 } |
3135 | 3980 |
3136 } // namespace wayland | 3981 } // namespace wayland |
3137 } // namespace exo | 3982 } // namespace exo |
OLD | NEW |