| 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 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1513 | 1513 |
| 1514 void remote_surface_set_system_modal(wl_client* client, wl_resource* resource) { | 1514 void remote_surface_set_system_modal(wl_client* client, wl_resource* resource) { |
| 1515 GetUserDataAs<ShellSurface>(resource)->SetSystemModal(true); | 1515 GetUserDataAs<ShellSurface>(resource)->SetSystemModal(true); |
| 1516 } | 1516 } |
| 1517 | 1517 |
| 1518 void remote_surface_unset_system_modal(wl_client* client, | 1518 void remote_surface_unset_system_modal(wl_client* client, |
| 1519 wl_resource* resource) { | 1519 wl_resource* resource) { |
| 1520 GetUserDataAs<ShellSurface>(resource)->SetSystemModal(false); | 1520 GetUserDataAs<ShellSurface>(resource)->SetSystemModal(false); |
| 1521 } | 1521 } |
| 1522 | 1522 |
| 1523 void remote_surface_set_rectangular_shadow_background_opacity( |
| 1524 wl_client* client, |
| 1525 wl_resource* resource, |
| 1526 wl_fixed_t opacity) { |
| 1527 GetUserDataAs<ShellSurface>(resource)->SetRectangularShadowBackgroundOpacity( |
| 1528 wl_fixed_to_double(opacity)); |
| 1529 } |
| 1530 |
| 1523 const struct zwp_remote_surface_v1_interface remote_surface_implementation = { | 1531 const struct zwp_remote_surface_v1_interface remote_surface_implementation = { |
| 1524 remote_surface_destroy, | 1532 remote_surface_destroy, |
| 1525 remote_surface_set_app_id, | 1533 remote_surface_set_app_id, |
| 1526 remote_surface_set_window_geometry, | 1534 remote_surface_set_window_geometry, |
| 1527 remote_surface_set_scale, | 1535 remote_surface_set_scale, |
| 1528 remote_surface_fullscreen, | 1536 remote_surface_fullscreen, |
| 1529 remote_surface_maximize, | 1537 remote_surface_maximize, |
| 1530 remote_surface_minimize, | 1538 remote_surface_minimize, |
| 1531 remote_surface_restore, | 1539 remote_surface_restore, |
| 1532 remote_surface_pin, | 1540 remote_surface_pin, |
| 1533 remote_surface_unpin, | 1541 remote_surface_unpin, |
| 1534 remote_surface_unfullscreen, | 1542 remote_surface_unfullscreen, |
| 1535 remote_surface_set_rectangular_shadow, | 1543 remote_surface_set_rectangular_shadow, |
| 1536 remote_surface_set_title, | 1544 remote_surface_set_title, |
| 1537 remote_surface_set_top_inset, | 1545 remote_surface_set_top_inset, |
| 1538 remote_surface_set_system_modal, | 1546 remote_surface_set_system_modal, |
| 1539 remote_surface_unset_system_modal}; | 1547 remote_surface_unset_system_modal, |
| 1548 remote_surface_set_rectangular_shadow_background_opacity}; |
| 1540 | 1549 |
| 1541 //////////////////////////////////////////////////////////////////////////////// | 1550 //////////////////////////////////////////////////////////////////////////////// |
| 1542 // notification_surface_interface: | 1551 // notification_surface_interface: |
| 1543 | 1552 |
| 1544 void notification_surface_destroy(wl_client* client, wl_resource* resource) { | 1553 void notification_surface_destroy(wl_client* client, wl_resource* resource) { |
| 1545 wl_resource_destroy(resource); | 1554 wl_resource_destroy(resource); |
| 1546 } | 1555 } |
| 1547 | 1556 |
| 1548 const struct zwp_notification_surface_v1_interface | 1557 const struct zwp_notification_surface_v1_interface |
| 1549 notification_surface_implementation = {notification_surface_destroy}; | 1558 notification_surface_implementation = {notification_surface_destroy}; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1561 int64_t display_id, | 1570 int64_t display_id, |
| 1562 wl_resource* remote_shell_resource) | 1571 wl_resource* remote_shell_resource) |
| 1563 : display_(display), | 1572 : display_(display), |
| 1564 display_id_(display_id), | 1573 display_id_(display_id), |
| 1565 remote_shell_resource_(remote_shell_resource), | 1574 remote_shell_resource_(remote_shell_resource), |
| 1566 weak_ptr_factory_(this) { | 1575 weak_ptr_factory_(this) { |
| 1567 ash::WmShell::Get()->AddShellObserver(this); | 1576 ash::WmShell::Get()->AddShellObserver(this); |
| 1568 ash::Shell* shell = ash::Shell::GetInstance(); | 1577 ash::Shell* shell = ash::Shell::GetInstance(); |
| 1569 shell->activation_client()->AddObserver(this); | 1578 shell->activation_client()->AddObserver(this); |
| 1570 display::Screen::GetScreen()->AddObserver(this); | 1579 display::Screen::GetScreen()->AddObserver(this); |
| 1571 SendConfigure(); | 1580 SendPrimaryDisplayMetrics(); |
| 1572 SendActivated(shell->activation_client()->GetActiveWindow(), nullptr); | 1581 SendActivated(shell->activation_client()->GetActiveWindow(), nullptr); |
| 1573 } | 1582 } |
| 1574 ~WaylandRemoteShell() override { | 1583 ~WaylandRemoteShell() override { |
| 1575 ash::WmShell::Get()->RemoveShellObserver(this); | 1584 ash::WmShell::Get()->RemoveShellObserver(this); |
| 1576 ash::Shell::GetInstance()->activation_client()->RemoveObserver(this); | 1585 ash::Shell::GetInstance()->activation_client()->RemoveObserver(this); |
| 1577 display::Screen::GetScreen()->RemoveObserver(this); | 1586 display::Screen::GetScreen()->RemoveObserver(this); |
| 1578 } | 1587 } |
| 1579 | 1588 |
| 1580 std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface, | 1589 std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface, |
| 1581 int container) { | 1590 int container) { |
| 1582 return display_->CreateRemoteShellSurface(surface, container); | 1591 return display_->CreateRemoteShellSurface(surface, container); |
| 1583 } | 1592 } |
| 1584 | 1593 |
| 1585 std::unique_ptr<NotificationSurface> CreateNotificationSurface( | 1594 std::unique_ptr<NotificationSurface> CreateNotificationSurface( |
| 1586 Surface* surface, | 1595 Surface* surface, |
| 1587 const std::string& notification_id) { | 1596 const std::string& notification_id) { |
| 1588 return display_->CreateNotificationSurface(surface, notification_id); | 1597 return display_->CreateNotificationSurface(surface, notification_id); |
| 1589 } | 1598 } |
| 1590 | 1599 |
| 1591 // Overridden from display::DisplayObserver: | 1600 // Overridden from display::DisplayObserver: |
| 1592 void OnDisplayAdded(const display::Display& new_display) override {} | 1601 void OnDisplayAdded(const display::Display& new_display) override {} |
| 1593 void OnDisplayRemoved(const display::Display& new_display) override {} | 1602 void OnDisplayRemoved(const display::Display& new_display) override {} |
| 1594 void OnDisplayMetricsChanged(const display::Display& display, | 1603 void OnDisplayMetricsChanged(const display::Display& display, |
| 1595 uint32_t metrics) override { | 1604 uint32_t changed_metrics) override { |
| 1596 if (display.id() == display_id_) | 1605 if (display.id() != display_id_) |
| 1597 SendConfigure(); | 1606 return; |
| 1607 |
| 1608 if (changed_metrics & |
| 1609 (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_DEVICE_SCALE_FACTOR | |
| 1610 DISPLAY_METRIC_ROTATION | DISPLAY_METRIC_WORK_AREA)) { |
| 1611 SendDisplayMetrics(display); |
| 1612 } |
| 1613 SendConfigure_DEPRECATED(display); |
| 1598 } | 1614 } |
| 1599 | 1615 |
| 1600 // Overridden from ash::ShellObserver: | 1616 // Overridden from ash::ShellObserver: |
| 1601 void OnDisplayWorkAreaInsetsChanged() override { SendConfigure(); } | 1617 void OnDisplayWorkAreaInsetsChanged() override { SendConfigure(); } |
| 1602 void OnMaximizeModeStarted() override { | 1618 void OnMaximizeModeStarted() override { |
| 1603 SendLayoutModeChange(ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET); | 1619 layout_mode_ = ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET; |
| 1620 SendLayoutModeChange_DEPRECATED(); |
| 1621 |
| 1604 send_configure_after_layout_change_ = true; | 1622 send_configure_after_layout_change_ = true; |
| 1605 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 1623 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 1606 FROM_HERE, base::Bind(&WaylandRemoteShell::MaybeSendConfigure, | 1624 FROM_HERE, base::Bind(&WaylandRemoteShell::MaybeSendConfigure, |
| 1607 weak_ptr_factory_.GetWeakPtr()), | 1625 weak_ptr_factory_.GetWeakPtr()), |
| 1608 base::TimeDelta::FromMilliseconds(kConfigureDelayAfterLayoutSwitchMs)); | 1626 base::TimeDelta::FromMilliseconds(kConfigureDelayAfterLayoutSwitchMs)); |
| 1609 } | 1627 } |
| 1610 void OnMaximizeModeEnded() override { | 1628 void OnMaximizeModeEnded() override { |
| 1611 SendLayoutModeChange(ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED); | 1629 layout_mode_ = ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED; |
| 1630 SendLayoutModeChange_DEPRECATED(); |
| 1612 send_configure_after_layout_change_ = true; | 1631 send_configure_after_layout_change_ = true; |
| 1613 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 1632 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 1614 FROM_HERE, base::Bind(&WaylandRemoteShell::MaybeSendConfigure, | 1633 FROM_HERE, base::Bind(&WaylandRemoteShell::MaybeSendConfigure, |
| 1615 weak_ptr_factory_.GetWeakPtr()), | 1634 weak_ptr_factory_.GetWeakPtr()), |
| 1616 base::TimeDelta::FromMilliseconds(kConfigureDelayAfterLayoutSwitchMs)); | 1635 base::TimeDelta::FromMilliseconds(kConfigureDelayAfterLayoutSwitchMs)); |
| 1617 } | 1636 } |
| 1618 | 1637 |
| 1619 // Overridden from aura::client::ActivationChangeObserver: | 1638 // Overridden from aura::client::ActivationChangeObserver: |
| 1620 void OnWindowActivated( | 1639 void OnWindowActivated( |
| 1621 aura::client::ActivationChangeObserver::ActivationReason reason, | 1640 aura::client::ActivationChangeObserver::ActivationReason reason, |
| 1622 aura::Window* gained_active, | 1641 aura::Window* gained_active, |
| 1623 aura::Window* lost_active) override { | 1642 aura::Window* lost_active) override { |
| 1624 SendActivated(gained_active, lost_active); | 1643 SendActivated(gained_active, lost_active); |
| 1625 } | 1644 } |
| 1626 | 1645 |
| 1627 private: | 1646 private: |
| 1647 void SendPrimaryDisplayMetrics() { |
| 1648 const display::Display& primary = |
| 1649 ash::Shell::GetInstance()->display_manager()->GetDisplayForId( |
| 1650 display_id_); |
| 1651 SendConfigure_DEPRECATED(primary); |
| 1652 SendDisplayMetrics(primary); |
| 1653 } |
| 1654 |
| 1628 void MaybeSendConfigure() { | 1655 void MaybeSendConfigure() { |
| 1629 if (send_configure_after_layout_change_) | 1656 if (send_configure_after_layout_change_) |
| 1630 SendConfigure(); | 1657 SendPrimaryDisplayMetrics(); |
| 1631 } | 1658 } |
| 1632 | 1659 |
| 1633 void SendConfigure() { | 1660 void SendDisplayMetrics(const display::Display& display) { |
| 1634 send_configure_after_layout_change_ = false; | 1661 send_configure_after_layout_change_ = false; |
| 1635 const display::Display& display = | 1662 |
| 1636 ash::Shell::GetInstance()->display_manager()->GetDisplayForId( | 1663 if (wl_resource_get_version(remote_shell_resource_) < 9) |
| 1637 display_id_); | 1664 return; |
| 1665 |
| 1666 const gfx::Insets& work_area_insets = display.GetWorkAreaInsets(); |
| 1667 |
| 1668 zwp_remote_shell_v1_send_configuration_changed( |
| 1669 remote_shell_resource_, display.size().width(), display.size().height(), |
| 1670 OutputTransform(display.rotation()), |
| 1671 wl_fixed_from_double(display.device_scale_factor()), |
| 1672 work_area_insets.left(), work_area_insets.top(), |
| 1673 work_area_insets.right(), work_area_insets.bottom(), layout_mode_); |
| 1674 |
| 1675 wl_client_flush(wl_resource_get_client(remote_shell_resource_)); |
| 1676 } |
| 1677 |
| 1678 void SendConfigure_DEPRECATED(const display::Display& display) { |
| 1679 send_configure_after_layout_change_ = false; |
| 1680 |
| 1681 if (wl_resource_get_version(remote_shell_resource_) >= 9) |
| 1682 return; |
| 1683 |
| 1638 gfx::Insets work_area_insets = display.GetWorkAreaInsets(); | 1684 gfx::Insets work_area_insets = display.GetWorkAreaInsets(); |
| 1639 zwp_remote_shell_v1_send_configure( | 1685 zwp_remote_shell_v1_send_configure( |
| 1640 remote_shell_resource_, display.size().width(), display.size().height(), | 1686 remote_shell_resource_, display.size().width(), display.size().height(), |
| 1641 work_area_insets.left(), work_area_insets.top(), | 1687 work_area_insets.left(), work_area_insets.top(), |
| 1642 work_area_insets.right(), work_area_insets.bottom()); | 1688 work_area_insets.right(), work_area_insets.bottom()); |
| 1643 wl_client_flush(wl_resource_get_client(remote_shell_resource_)); | 1689 wl_client_flush(wl_resource_get_client(remote_shell_resource_)); |
| 1644 } | 1690 } |
| 1645 | 1691 |
| 1646 void SendLayoutModeChange(uint32_t mode) { | 1692 void SendLayoutModeChange_DEPRECATED() { |
| 1647 if (wl_resource_get_version(remote_shell_resource_) < 8) | 1693 if (wl_resource_get_version(remote_shell_resource_) < 8) |
| 1648 return; | 1694 return; |
| 1649 zwp_remote_shell_v1_send_layout_mode_changed(remote_shell_resource_, mode); | 1695 zwp_remote_shell_v1_send_layout_mode_changed(remote_shell_resource_, |
| 1696 layout_mode_); |
| 1650 wl_client_flush(wl_resource_get_client(remote_shell_resource_)); | 1697 wl_client_flush(wl_resource_get_client(remote_shell_resource_)); |
| 1651 } | 1698 } |
| 1652 | 1699 |
| 1653 void SendActivated(aura::Window* gained_active, aura::Window* lost_active) { | 1700 void SendActivated(aura::Window* gained_active, aura::Window* lost_active) { |
| 1654 Surface* gained_active_surface = | 1701 Surface* gained_active_surface = |
| 1655 gained_active ? ShellSurface::GetMainSurface(gained_active) : nullptr; | 1702 gained_active ? ShellSurface::GetMainSurface(gained_active) : nullptr; |
| 1656 Surface* lost_active_surface = | 1703 Surface* lost_active_surface = |
| 1657 lost_active ? ShellSurface::GetMainSurface(lost_active) : nullptr; | 1704 lost_active ? ShellSurface::GetMainSurface(lost_active) : nullptr; |
| 1658 wl_resource* gained_active_surface_resource = | 1705 wl_resource* gained_active_surface_resource = |
| 1659 gained_active_surface ? GetSurfaceResource(gained_active_surface) | 1706 gained_active_surface ? GetSurfaceResource(gained_active_surface) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1687 Display* const display_; | 1734 Display* const display_; |
| 1688 | 1735 |
| 1689 // The identifier associated with the observed display. | 1736 // The identifier associated with the observed display. |
| 1690 const int64_t display_id_; | 1737 const int64_t display_id_; |
| 1691 | 1738 |
| 1692 // The remote shell resource associated with observer. | 1739 // The remote shell resource associated with observer. |
| 1693 wl_resource* const remote_shell_resource_; | 1740 wl_resource* const remote_shell_resource_; |
| 1694 | 1741 |
| 1695 bool send_configure_after_layout_change_ = false; | 1742 bool send_configure_after_layout_change_ = false; |
| 1696 | 1743 |
| 1744 int layout_mode_ = ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED; |
| 1745 |
| 1697 base::WeakPtrFactory<WaylandRemoteShell> weak_ptr_factory_; | 1746 base::WeakPtrFactory<WaylandRemoteShell> weak_ptr_factory_; |
| 1698 | 1747 |
| 1699 DISALLOW_COPY_AND_ASSIGN(WaylandRemoteShell); | 1748 DISALLOW_COPY_AND_ASSIGN(WaylandRemoteShell); |
| 1700 }; | 1749 }; |
| 1701 | 1750 |
| 1702 void remote_shell_destroy(wl_client* client, wl_resource* resource) { | 1751 void remote_shell_destroy(wl_client* client, wl_resource* resource) { |
| 1703 // Nothing to do here. | 1752 // Nothing to do here. |
| 1704 } | 1753 } |
| 1705 | 1754 |
| 1706 int RemoteSurfaceContainer(uint32_t container) { | 1755 int RemoteSurfaceContainer(uint32_t container) { |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1832 wl_resource_get_version(resource), id); | 1881 wl_resource_get_version(resource), id); |
| 1833 SetImplementation(notification_surface_resource, | 1882 SetImplementation(notification_surface_resource, |
| 1834 ¬ification_surface_implementation, | 1883 ¬ification_surface_implementation, |
| 1835 std::move(notification_surface)); | 1884 std::move(notification_surface)); |
| 1836 } | 1885 } |
| 1837 | 1886 |
| 1838 const struct zwp_remote_shell_v1_interface remote_shell_implementation = { | 1887 const struct zwp_remote_shell_v1_interface remote_shell_implementation = { |
| 1839 remote_shell_destroy, remote_shell_get_remote_surface, | 1888 remote_shell_destroy, remote_shell_get_remote_surface, |
| 1840 remote_shell_get_notification_surface}; | 1889 remote_shell_get_notification_surface}; |
| 1841 | 1890 |
| 1842 const uint32_t remote_shell_version = 8; | 1891 const uint32_t remote_shell_version = 9; |
| 1843 | 1892 |
| 1844 void bind_remote_shell(wl_client* client, | 1893 void bind_remote_shell(wl_client* client, |
| 1845 void* data, | 1894 void* data, |
| 1846 uint32_t version, | 1895 uint32_t version, |
| 1847 uint32_t id) { | 1896 uint32_t id) { |
| 1848 wl_resource* resource = | 1897 wl_resource* resource = |
| 1849 wl_resource_create(client, &zwp_remote_shell_v1_interface, | 1898 wl_resource_create(client, &zwp_remote_shell_v1_interface, |
| 1850 std::min(version, remote_shell_version), id); | 1899 std::min(version, remote_shell_version), id); |
| 1851 | 1900 |
| 1852 // TODO(reveman): Multi-display support. | 1901 // TODO(reveman): Multi-display support. |
| (...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2997 DCHECK(event_loop); | 3046 DCHECK(event_loop); |
| 2998 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); | 3047 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); |
| 2999 } | 3048 } |
| 3000 | 3049 |
| 3001 void Server::Flush() { | 3050 void Server::Flush() { |
| 3002 wl_display_flush_clients(wl_display_.get()); | 3051 wl_display_flush_clients(wl_display_.get()); |
| 3003 } | 3052 } |
| 3004 | 3053 |
| 3005 } // namespace wayland | 3054 } // namespace wayland |
| 3006 } // namespace exo | 3055 } // namespace exo |
| OLD | NEW |