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 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1514 | 1514 |
1515 void remote_surface_set_system_modal(wl_client* client, wl_resource* resource) { | 1515 void remote_surface_set_system_modal(wl_client* client, wl_resource* resource) { |
1516 GetUserDataAs<ShellSurface>(resource)->SetSystemModal(true); | 1516 GetUserDataAs<ShellSurface>(resource)->SetSystemModal(true); |
1517 } | 1517 } |
1518 | 1518 |
1519 void remote_surface_unset_system_modal(wl_client* client, | 1519 void remote_surface_unset_system_modal(wl_client* client, |
1520 wl_resource* resource) { | 1520 wl_resource* resource) { |
1521 GetUserDataAs<ShellSurface>(resource)->SetSystemModal(false); | 1521 GetUserDataAs<ShellSurface>(resource)->SetSystemModal(false); |
1522 } | 1522 } |
1523 | 1523 |
| 1524 void remote_surface_set_rectangular_shadow_background_opacity( |
| 1525 wl_client* client, |
| 1526 wl_resource* resource, |
| 1527 wl_fixed_t opacity) { |
| 1528 GetUserDataAs<ShellSurface>(resource)->SetRectangularShadowBackgroundOpacity( |
| 1529 wl_fixed_to_double(opacity)); |
| 1530 } |
| 1531 |
1524 const struct zwp_remote_surface_v1_interface remote_surface_implementation = { | 1532 const struct zwp_remote_surface_v1_interface remote_surface_implementation = { |
1525 remote_surface_destroy, | 1533 remote_surface_destroy, |
1526 remote_surface_set_app_id, | 1534 remote_surface_set_app_id, |
1527 remote_surface_set_window_geometry, | 1535 remote_surface_set_window_geometry, |
1528 remote_surface_set_scale, | 1536 remote_surface_set_scale, |
1529 remote_surface_fullscreen, | 1537 remote_surface_fullscreen, |
1530 remote_surface_maximize, | 1538 remote_surface_maximize, |
1531 remote_surface_minimize, | 1539 remote_surface_minimize, |
1532 remote_surface_restore, | 1540 remote_surface_restore, |
1533 remote_surface_pin, | 1541 remote_surface_pin, |
1534 remote_surface_unpin, | 1542 remote_surface_unpin, |
1535 remote_surface_unfullscreen, | 1543 remote_surface_unfullscreen, |
1536 remote_surface_set_rectangular_shadow, | 1544 remote_surface_set_rectangular_shadow, |
1537 remote_surface_set_title, | 1545 remote_surface_set_title, |
1538 remote_surface_set_top_inset, | 1546 remote_surface_set_top_inset, |
1539 remote_surface_set_system_modal, | 1547 remote_surface_set_system_modal, |
1540 remote_surface_unset_system_modal}; | 1548 remote_surface_unset_system_modal, |
| 1549 remote_surface_set_rectangular_shadow_background_opacity}; |
1541 | 1550 |
1542 //////////////////////////////////////////////////////////////////////////////// | 1551 //////////////////////////////////////////////////////////////////////////////// |
1543 // notification_surface_interface: | 1552 // notification_surface_interface: |
1544 | 1553 |
1545 void notification_surface_destroy(wl_client* client, wl_resource* resource) { | 1554 void notification_surface_destroy(wl_client* client, wl_resource* resource) { |
1546 wl_resource_destroy(resource); | 1555 wl_resource_destroy(resource); |
1547 } | 1556 } |
1548 | 1557 |
1549 const struct zwp_notification_surface_v1_interface | 1558 const struct zwp_notification_surface_v1_interface |
1550 notification_surface_implementation = {notification_surface_destroy}; | 1559 notification_surface_implementation = {notification_surface_destroy}; |
(...skipping 11 matching lines...) Expand all Loading... |
1562 int64_t display_id, | 1571 int64_t display_id, |
1563 wl_resource* remote_shell_resource) | 1572 wl_resource* remote_shell_resource) |
1564 : display_(display), | 1573 : display_(display), |
1565 display_id_(display_id), | 1574 display_id_(display_id), |
1566 remote_shell_resource_(remote_shell_resource), | 1575 remote_shell_resource_(remote_shell_resource), |
1567 weak_ptr_factory_(this) { | 1576 weak_ptr_factory_(this) { |
1568 ash::WmShell::Get()->AddShellObserver(this); | 1577 ash::WmShell::Get()->AddShellObserver(this); |
1569 ash::Shell* shell = ash::Shell::GetInstance(); | 1578 ash::Shell* shell = ash::Shell::GetInstance(); |
1570 shell->activation_client()->AddObserver(this); | 1579 shell->activation_client()->AddObserver(this); |
1571 display::Screen::GetScreen()->AddObserver(this); | 1580 display::Screen::GetScreen()->AddObserver(this); |
1572 SendConfigure(); | 1581 SendPrimaryDisplayMetrics(); |
1573 SendActivated(shell->activation_client()->GetActiveWindow(), nullptr); | 1582 SendActivated(shell->activation_client()->GetActiveWindow(), nullptr); |
1574 } | 1583 } |
1575 ~WaylandRemoteShell() override { | 1584 ~WaylandRemoteShell() override { |
1576 ash::WmShell::Get()->RemoveShellObserver(this); | 1585 ash::WmShell::Get()->RemoveShellObserver(this); |
1577 ash::Shell::GetInstance()->activation_client()->RemoveObserver(this); | 1586 ash::Shell::GetInstance()->activation_client()->RemoveObserver(this); |
1578 display::Screen::GetScreen()->RemoveObserver(this); | 1587 display::Screen::GetScreen()->RemoveObserver(this); |
1579 } | 1588 } |
1580 | 1589 |
1581 std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface, | 1590 std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface, |
1582 int container) { | 1591 int container) { |
1583 return display_->CreateRemoteShellSurface(surface, container); | 1592 return display_->CreateRemoteShellSurface(surface, container); |
1584 } | 1593 } |
1585 | 1594 |
1586 std::unique_ptr<NotificationSurface> CreateNotificationSurface( | 1595 std::unique_ptr<NotificationSurface> CreateNotificationSurface( |
1587 Surface* surface, | 1596 Surface* surface, |
1588 const std::string& notification_id) { | 1597 const std::string& notification_id) { |
1589 return display_->CreateNotificationSurface(surface, notification_id); | 1598 return display_->CreateNotificationSurface(surface, notification_id); |
1590 } | 1599 } |
1591 | 1600 |
1592 // Overridden from display::DisplayObserver: | 1601 // Overridden from display::DisplayObserver: |
1593 void OnDisplayAdded(const display::Display& new_display) override {} | 1602 void OnDisplayAdded(const display::Display& new_display) override {} |
1594 void OnDisplayRemoved(const display::Display& new_display) override {} | 1603 void OnDisplayRemoved(const display::Display& new_display) override {} |
1595 void OnDisplayMetricsChanged(const display::Display& display, | 1604 void OnDisplayMetricsChanged(const display::Display& display, |
1596 uint32_t metrics) override { | 1605 uint32_t changed_metrics) override { |
1597 if (display.id() == display_id_) | 1606 if (display.id() != display_id_) |
1598 SendConfigure(); | 1607 return; |
| 1608 |
| 1609 if (changed_metrics & |
| 1610 (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_DEVICE_SCALE_FACTOR | |
| 1611 DISPLAY_METRIC_ROTATION | DISPLAY_METRIC_WORK_AREA)) { |
| 1612 SendDisplayMetrics(display); |
| 1613 } |
| 1614 SendConfigure_DEPRECATED(display); |
1599 } | 1615 } |
1600 | 1616 |
1601 // Overridden from ash::ShellObserver: | 1617 // Overridden from ash::ShellObserver: |
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 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3074 DCHECK(event_loop); | 3123 DCHECK(event_loop); |
3075 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); | 3124 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); |
3076 } | 3125 } |
3077 | 3126 |
3078 void Server::Flush() { | 3127 void Server::Flush() { |
3079 wl_display_flush_clients(wl_display_.get()); | 3128 wl_display_flush_clients(wl_display_.get()); |
3080 } | 3129 } |
3081 | 3130 |
3082 } // namespace wayland | 3131 } // namespace wayland |
3083 } // namespace exo | 3132 } // namespace exo |
OLD | NEW |