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 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1490 GetUserDataAs<ShellSurface>(resource)->SetTitle( | 1490 GetUserDataAs<ShellSurface>(resource)->SetTitle( |
1491 base::string16(base::UTF8ToUTF16(title))); | 1491 base::string16(base::UTF8ToUTF16(title))); |
1492 } | 1492 } |
1493 | 1493 |
1494 void remote_surface_set_top_inset(wl_client* client, | 1494 void remote_surface_set_top_inset(wl_client* client, |
1495 wl_resource* resource, | 1495 wl_resource* resource, |
1496 int32_t height) { | 1496 int32_t height) { |
1497 GetUserDataAs<ShellSurface>(resource)->SetTopInset(height); | 1497 GetUserDataAs<ShellSurface>(resource)->SetTopInset(height); |
1498 } | 1498 } |
1499 | 1499 |
| 1500 void remote_surface_set_system_modal(wl_client* client, wl_resource* resource) { |
| 1501 GetUserDataAs<ShellSurface>(resource)->SetSystemModal(true); |
| 1502 } |
| 1503 |
| 1504 void remote_surface_unset_system_modal(wl_client* client, |
| 1505 wl_resource* resource) { |
| 1506 GetUserDataAs<ShellSurface>(resource)->SetSystemModal(false); |
| 1507 } |
| 1508 |
1500 const struct zwp_remote_surface_v1_interface remote_surface_implementation = { | 1509 const struct zwp_remote_surface_v1_interface remote_surface_implementation = { |
1501 remote_surface_destroy, | 1510 remote_surface_destroy, |
1502 remote_surface_set_app_id, | 1511 remote_surface_set_app_id, |
1503 remote_surface_set_window_geometry, | 1512 remote_surface_set_window_geometry, |
1504 remote_surface_set_scale, | 1513 remote_surface_set_scale, |
1505 remote_surface_fullscreen, | 1514 remote_surface_fullscreen, |
1506 remote_surface_maximize, | 1515 remote_surface_maximize, |
1507 remote_surface_minimize, | 1516 remote_surface_minimize, |
1508 remote_surface_restore, | 1517 remote_surface_restore, |
1509 remote_surface_pin, | 1518 remote_surface_pin, |
1510 remote_surface_unpin, | 1519 remote_surface_unpin, |
1511 remote_surface_unfullscreen, | 1520 remote_surface_unfullscreen, |
1512 remote_surface_set_rectangular_shadow, | 1521 remote_surface_set_rectangular_shadow, |
1513 remote_surface_set_title, | 1522 remote_surface_set_title, |
1514 remote_surface_set_top_inset}; | 1523 remote_surface_set_top_inset, |
| 1524 remote_surface_set_system_modal, |
| 1525 remote_surface_unset_system_modal}; |
1515 | 1526 |
1516 //////////////////////////////////////////////////////////////////////////////// | 1527 //////////////////////////////////////////////////////////////////////////////// |
1517 // notification_surface_interface: | 1528 // notification_surface_interface: |
1518 | 1529 |
1519 void notification_surface_destroy(wl_client* client, wl_resource* resource) { | 1530 void notification_surface_destroy(wl_client* client, wl_resource* resource) { |
1520 wl_resource_destroy(resource); | 1531 wl_resource_destroy(resource); |
1521 } | 1532 } |
1522 | 1533 |
1523 const struct zwp_notification_surface_v1_interface | 1534 const struct zwp_notification_surface_v1_interface |
1524 notification_surface_implementation = {notification_surface_destroy}; | 1535 notification_surface_implementation = {notification_surface_destroy}; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1566 void OnDisplayAdded(const display::Display& new_display) override {} | 1577 void OnDisplayAdded(const display::Display& new_display) override {} |
1567 void OnDisplayRemoved(const display::Display& new_display) override {} | 1578 void OnDisplayRemoved(const display::Display& new_display) override {} |
1568 void OnDisplayMetricsChanged(const display::Display& display, | 1579 void OnDisplayMetricsChanged(const display::Display& display, |
1569 uint32_t metrics) override { | 1580 uint32_t metrics) override { |
1570 if (display.id() == display_id_) | 1581 if (display.id() == display_id_) |
1571 SendConfigure(); | 1582 SendConfigure(); |
1572 } | 1583 } |
1573 | 1584 |
1574 // Overridden from ash::ShellObserver: | 1585 // Overridden from ash::ShellObserver: |
1575 void OnDisplayWorkAreaInsetsChanged() override { SendConfigure(); } | 1586 void OnDisplayWorkAreaInsetsChanged() override { SendConfigure(); } |
| 1587 void OnMaximizeModeStarted() override { |
| 1588 SendLayoutModeChange(ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET); |
| 1589 } |
| 1590 void OnMaximizeModeEnded() override { |
| 1591 SendLayoutModeChange(ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED); |
| 1592 } |
1576 | 1593 |
1577 // Overridden from aura::client::ActivationChangeObserver: | 1594 // Overridden from aura::client::ActivationChangeObserver: |
1578 void OnWindowActivated( | 1595 void OnWindowActivated( |
1579 aura::client::ActivationChangeObserver::ActivationReason reason, | 1596 aura::client::ActivationChangeObserver::ActivationReason reason, |
1580 aura::Window* gained_active, | 1597 aura::Window* gained_active, |
1581 aura::Window* lost_active) override { | 1598 aura::Window* lost_active) override { |
1582 SendActivated(gained_active, lost_active); | 1599 SendActivated(gained_active, lost_active); |
1583 } | 1600 } |
1584 | 1601 |
1585 private: | 1602 private: |
1586 void SendConfigure() { | 1603 void SendConfigure() { |
1587 const display::Display& display = | 1604 const display::Display& display = |
1588 ash::Shell::GetInstance()->display_manager()->GetDisplayForId( | 1605 ash::Shell::GetInstance()->display_manager()->GetDisplayForId( |
1589 display_id_); | 1606 display_id_); |
1590 gfx::Insets work_area_insets = display.GetWorkAreaInsets(); | 1607 gfx::Insets work_area_insets = display.GetWorkAreaInsets(); |
1591 zwp_remote_shell_v1_send_configure( | 1608 zwp_remote_shell_v1_send_configure( |
1592 remote_shell_resource_, display.size().width(), display.size().height(), | 1609 remote_shell_resource_, display.size().width(), display.size().height(), |
1593 work_area_insets.left(), work_area_insets.top(), | 1610 work_area_insets.left(), work_area_insets.top(), |
1594 work_area_insets.right(), work_area_insets.bottom()); | 1611 work_area_insets.right(), work_area_insets.bottom()); |
1595 wl_client_flush(wl_resource_get_client(remote_shell_resource_)); | 1612 wl_client_flush(wl_resource_get_client(remote_shell_resource_)); |
1596 } | 1613 } |
1597 | 1614 |
| 1615 void SendLayoutModeChange(int mode) { |
| 1616 if (wl_resource_get_version(remote_shell_resource_) < 8) |
| 1617 return; |
| 1618 zwp_remote_shell_v1_send_layout_mode_changed(remote_shell_resource_, mode); |
| 1619 wl_client_flush(wl_resource_get_client(remote_shell_resource_)); |
| 1620 } |
| 1621 |
1598 void SendActivated(aura::Window* gained_active, aura::Window* lost_active) { | 1622 void SendActivated(aura::Window* gained_active, aura::Window* lost_active) { |
1599 Surface* gained_active_surface = | 1623 Surface* gained_active_surface = |
1600 gained_active ? ShellSurface::GetMainSurface(gained_active) : nullptr; | 1624 gained_active ? ShellSurface::GetMainSurface(gained_active) : nullptr; |
1601 Surface* lost_active_surface = | 1625 Surface* lost_active_surface = |
1602 lost_active ? ShellSurface::GetMainSurface(lost_active) : nullptr; | 1626 lost_active ? ShellSurface::GetMainSurface(lost_active) : nullptr; |
1603 wl_resource* gained_active_surface_resource = | 1627 wl_resource* gained_active_surface_resource = |
1604 gained_active_surface ? GetSurfaceResource(gained_active_surface) | 1628 gained_active_surface ? GetSurfaceResource(gained_active_surface) |
1605 : nullptr; | 1629 : nullptr; |
1606 wl_resource* lost_active_surface_resource = | 1630 wl_resource* lost_active_surface_resource = |
1607 lost_active_surface ? GetSurfaceResource(lost_active_surface) : nullptr; | 1631 lost_active_surface ? GetSurfaceResource(lost_active_surface) : nullptr; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1773 wl_resource_get_version(resource), id); | 1797 wl_resource_get_version(resource), id); |
1774 SetImplementation(notification_surface_resource, | 1798 SetImplementation(notification_surface_resource, |
1775 ¬ification_surface_implementation, | 1799 ¬ification_surface_implementation, |
1776 std::move(notification_surface)); | 1800 std::move(notification_surface)); |
1777 } | 1801 } |
1778 | 1802 |
1779 const struct zwp_remote_shell_v1_interface remote_shell_implementation = { | 1803 const struct zwp_remote_shell_v1_interface remote_shell_implementation = { |
1780 remote_shell_destroy, remote_shell_get_remote_surface, | 1804 remote_shell_destroy, remote_shell_get_remote_surface, |
1781 remote_shell_get_notification_surface}; | 1805 remote_shell_get_notification_surface}; |
1782 | 1806 |
1783 const uint32_t remote_shell_version = 6; | 1807 const uint32_t remote_shell_version = 8; |
1784 | 1808 |
1785 void bind_remote_shell(wl_client* client, | 1809 void bind_remote_shell(wl_client* client, |
1786 void* data, | 1810 void* data, |
1787 uint32_t version, | 1811 uint32_t version, |
1788 uint32_t id) { | 1812 uint32_t id) { |
1789 wl_resource* resource = | 1813 wl_resource* resource = |
1790 wl_resource_create(client, &zwp_remote_shell_v1_interface, | 1814 wl_resource_create(client, &zwp_remote_shell_v1_interface, |
1791 std::min(version, remote_shell_version), id); | 1815 std::min(version, remote_shell_version), id); |
1792 | 1816 |
1793 // TODO(reveman): Multi-display support. | 1817 // TODO(reveman): Multi-display support. |
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2846 DCHECK(event_loop); | 2870 DCHECK(event_loop); |
2847 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); | 2871 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); |
2848 } | 2872 } |
2849 | 2873 |
2850 void Server::Flush() { | 2874 void Server::Flush() { |
2851 wl_display_flush_clients(wl_display_.get()); | 2875 wl_display_flush_clients(wl_display_.get()); |
2852 } | 2876 } |
2853 | 2877 |
2854 } // namespace wayland | 2878 } // namespace wayland |
2855 } // namespace exo | 2879 } // namespace exo |
OLD | NEW |