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