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 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1031 return WL_OUTPUT_TRANSFORM_180; | 1031 return WL_OUTPUT_TRANSFORM_180; |
1032 case display::Display::ROTATE_270: | 1032 case display::Display::ROTATE_270: |
1033 return WL_OUTPUT_TRANSFORM_270; | 1033 return WL_OUTPUT_TRANSFORM_270; |
1034 } | 1034 } |
1035 NOTREACHED(); | 1035 NOTREACHED(); |
1036 return WL_OUTPUT_TRANSFORM_NORMAL; | 1036 return WL_OUTPUT_TRANSFORM_NORMAL; |
1037 } | 1037 } |
1038 | 1038 |
1039 class WaylandDisplayObserver : public display::DisplayObserver { | 1039 class WaylandDisplayObserver : public display::DisplayObserver { |
1040 public: | 1040 public: |
1041 WaylandDisplayObserver(const display::Display& display, | 1041 WaylandDisplayObserver(wl_resource* output_resource) |
1042 wl_resource* output_resource) | 1042 : output_resource_(output_resource) { |
1043 : display_id_(display.id()), output_resource_(output_resource) { | |
1044 display::Screen::GetScreen()->AddObserver(this); | 1043 display::Screen::GetScreen()->AddObserver(this); |
1045 SendDisplayMetrics(display); | 1044 SendPrimaryDisplayMetrics(); |
1046 } | 1045 } |
1047 ~WaylandDisplayObserver() override { | 1046 ~WaylandDisplayObserver() override { |
1048 display::Screen::GetScreen()->RemoveObserver(this); | 1047 display::Screen::GetScreen()->RemoveObserver(this); |
1049 } | 1048 } |
1050 | 1049 |
1051 // Overridden from display::DisplayObserver: | 1050 // Overridden from display::DisplayObserver: |
1052 void OnDisplayAdded(const display::Display& new_display) override {} | 1051 void OnDisplayAdded(const display::Display& new_display) override {} |
1053 void OnDisplayRemoved(const display::Display& new_display) override {} | 1052 void OnDisplayRemoved(const display::Display& new_display) override {} |
1054 void OnDisplayMetricsChanged(const display::Display& display, | 1053 void OnDisplayMetricsChanged(const display::Display& display, |
1055 uint32_t changed_metrics) override { | 1054 uint32_t changed_metrics) override { |
1056 if (display.id() != display_id_) | 1055 if (display::Screen::GetScreen()->GetPrimaryDisplay().id() != display.id()) |
1057 return; | 1056 return; |
1058 | 1057 |
1059 if (changed_metrics & | 1058 if (changed_metrics & |
1060 (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_DEVICE_SCALE_FACTOR | | 1059 (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_DEVICE_SCALE_FACTOR | |
1061 DISPLAY_METRIC_ROTATION)) { | 1060 DISPLAY_METRIC_ROTATION)) { |
1062 SendDisplayMetrics(display); | 1061 SendPrimaryDisplayMetrics(); |
1063 } | 1062 } |
1064 } | 1063 } |
1065 | 1064 |
1066 private: | 1065 private: |
1067 void SendDisplayMetrics(const display::Display& display) { | 1066 void SendPrimaryDisplayMetrics() { |
1067 // TODO(reveman): Multi-display support. | |
1068 display::Display display = | |
1069 display::Screen::GetScreen()->GetPrimaryDisplay(); | |
1070 | |
1068 const ash::DisplayInfo& info = | 1071 const ash::DisplayInfo& info = |
1069 ash::Shell::GetInstance()->display_manager()->GetDisplayInfo( | 1072 ash::Shell::GetInstance()->display_manager()->GetDisplayInfo( |
1070 display.id()); | 1073 display.id()); |
1071 | 1074 |
1072 const float kInchInMm = 25.4f; | 1075 const float kInchInMm = 25.4f; |
1073 const char* kUnknownMake = "unknown"; | 1076 const char* kUnknownMake = "unknown"; |
1074 const char* kUnknownModel = "unknown"; | 1077 const char* kUnknownModel = "unknown"; |
1075 | 1078 |
1076 gfx::Rect bounds = info.bounds_in_native(); | 1079 gfx::Rect bounds = info.bounds_in_native(); |
1077 wl_output_send_geometry( | 1080 wl_output_send_geometry( |
(...skipping 12 matching lines...) Expand all Loading... | |
1090 wl_output_send_mode( | 1093 wl_output_send_mode( |
1091 output_resource_, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED, | 1094 output_resource_, WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED, |
1092 bounds.width(), bounds.height(), static_cast<int>(60000)); | 1095 bounds.width(), bounds.height(), static_cast<int>(60000)); |
1093 | 1096 |
1094 if (wl_resource_get_version(output_resource_) >= | 1097 if (wl_resource_get_version(output_resource_) >= |
1095 WL_OUTPUT_DONE_SINCE_VERSION) { | 1098 WL_OUTPUT_DONE_SINCE_VERSION) { |
1096 wl_output_send_done(output_resource_); | 1099 wl_output_send_done(output_resource_); |
1097 } | 1100 } |
1098 } | 1101 } |
1099 | 1102 |
1100 // The identifier associated with the observed display. | |
1101 const int64_t display_id_; | |
1102 | |
1103 // The output resource associated with the display. | 1103 // The output resource associated with the display. |
1104 wl_resource* const output_resource_; | 1104 wl_resource* const output_resource_; |
1105 | 1105 |
1106 DISALLOW_COPY_AND_ASSIGN(WaylandDisplayObserver); | 1106 DISALLOW_COPY_AND_ASSIGN(WaylandDisplayObserver); |
1107 }; | 1107 }; |
1108 | 1108 |
1109 const uint32_t output_version = 2; | 1109 const uint32_t output_version = 2; |
1110 | 1110 |
1111 void bind_output(wl_client* client, void* data, uint32_t version, uint32_t id) { | 1111 void bind_output(wl_client* client, void* data, uint32_t version, uint32_t id) { |
1112 wl_resource* resource = wl_resource_create( | 1112 wl_resource* resource = wl_resource_create( |
1113 client, &wl_output_interface, std::min(version, output_version), id); | 1113 client, &wl_output_interface, std::min(version, output_version), id); |
1114 | 1114 |
1115 // TODO(reveman): Multi-display support. | 1115 SetImplementation(resource, nullptr, |
1116 const display::Display& display = ash::Shell::GetInstance() | 1116 base::WrapUnique(new WaylandDisplayObserver(resource))); |
1117 ->display_manager() | |
1118 ->GetPrimaryDisplayCandidate(); | |
1119 | |
1120 SetImplementation( | |
1121 resource, nullptr, | |
1122 base::WrapUnique(new WaylandDisplayObserver(display, resource))); | |
1123 } | 1117 } |
1124 | 1118 |
1125 //////////////////////////////////////////////////////////////////////////////// | 1119 //////////////////////////////////////////////////////////////////////////////// |
1126 // xdg_surface_interface: | 1120 // xdg_surface_interface: |
1127 | 1121 |
1128 int XdgResizeComponent(uint32_t edges) { | 1122 int XdgResizeComponent(uint32_t edges) { |
1129 switch (edges) { | 1123 switch (edges) { |
1130 case XDG_SURFACE_RESIZE_EDGE_TOP: | 1124 case XDG_SURFACE_RESIZE_EDGE_TOP: |
1131 return HTTOP; | 1125 return HTTOP; |
1132 case XDG_SURFACE_RESIZE_EDGE_BOTTOM: | 1126 case XDG_SURFACE_RESIZE_EDGE_BOTTOM: |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1512 | 1506 |
1513 void remote_surface_set_system_modal(wl_client* client, wl_resource* resource) { | 1507 void remote_surface_set_system_modal(wl_client* client, wl_resource* resource) { |
1514 GetUserDataAs<ShellSurface>(resource)->SetSystemModal(true); | 1508 GetUserDataAs<ShellSurface>(resource)->SetSystemModal(true); |
1515 } | 1509 } |
1516 | 1510 |
1517 void remote_surface_unset_system_modal(wl_client* client, | 1511 void remote_surface_unset_system_modal(wl_client* client, |
1518 wl_resource* resource) { | 1512 wl_resource* resource) { |
1519 GetUserDataAs<ShellSurface>(resource)->SetSystemModal(false); | 1513 GetUserDataAs<ShellSurface>(resource)->SetSystemModal(false); |
1520 } | 1514 } |
1521 | 1515 |
1516 void remote_surface_set_rectangular_shadow_background_opacity( | |
1517 wl_client* client, | |
1518 wl_resource* resource, | |
1519 wl_fixed_t opacity) { | |
1520 GetUserDataAs<ShellSurface>(resource)->SetRectangularShadowBackgroundOpacity( | |
1521 wl_fixed_to_double(opacity)); | |
1522 } | |
1523 | |
1522 const struct zwp_remote_surface_v1_interface remote_surface_implementation = { | 1524 const struct zwp_remote_surface_v1_interface remote_surface_implementation = { |
1523 remote_surface_destroy, | 1525 remote_surface_destroy, |
1524 remote_surface_set_app_id, | 1526 remote_surface_set_app_id, |
1525 remote_surface_set_window_geometry, | 1527 remote_surface_set_window_geometry, |
1526 remote_surface_set_scale, | 1528 remote_surface_set_scale, |
1527 remote_surface_fullscreen, | 1529 remote_surface_fullscreen, |
1528 remote_surface_maximize, | 1530 remote_surface_maximize, |
1529 remote_surface_minimize, | 1531 remote_surface_minimize, |
1530 remote_surface_restore, | 1532 remote_surface_restore, |
1531 remote_surface_pin, | 1533 remote_surface_pin, |
1532 remote_surface_unpin, | 1534 remote_surface_unpin, |
1533 remote_surface_unfullscreen, | 1535 remote_surface_unfullscreen, |
1534 remote_surface_set_rectangular_shadow, | 1536 remote_surface_set_rectangular_shadow, |
1535 remote_surface_set_title, | 1537 remote_surface_set_title, |
1536 remote_surface_set_top_inset, | 1538 remote_surface_set_top_inset, |
1537 remote_surface_set_system_modal, | 1539 remote_surface_set_system_modal, |
1538 remote_surface_unset_system_modal}; | 1540 remote_surface_unset_system_modal, |
1541 remote_surface_set_rectangular_shadow_background_opacity}; | |
1539 | 1542 |
1540 //////////////////////////////////////////////////////////////////////////////// | 1543 //////////////////////////////////////////////////////////////////////////////// |
1541 // notification_surface_interface: | 1544 // notification_surface_interface: |
1542 | 1545 |
1543 void notification_surface_destroy(wl_client* client, wl_resource* resource) { | 1546 void notification_surface_destroy(wl_client* client, wl_resource* resource) { |
1544 wl_resource_destroy(resource); | 1547 wl_resource_destroy(resource); |
1545 } | 1548 } |
1546 | 1549 |
1547 const struct zwp_notification_surface_v1_interface | 1550 const struct zwp_notification_surface_v1_interface |
1548 notification_surface_implementation = {notification_surface_destroy}; | 1551 notification_surface_implementation = {notification_surface_destroy}; |
1549 | 1552 |
1550 //////////////////////////////////////////////////////////////////////////////// | 1553 //////////////////////////////////////////////////////////////////////////////// |
1551 // remote_shell_interface: | 1554 // remote_shell_interface: |
1552 | 1555 |
1553 // Implements remote shell interface and monitors workspace state needed | 1556 // Implements remote shell interface and monitors workspace state needed |
1554 // for the remote shell interface. | 1557 // for the remote shell interface. |
1555 class WaylandRemoteShell : public ash::ShellObserver, | 1558 class WaylandRemoteShell : public ash::ShellObserver, |
1556 public aura::client::ActivationChangeObserver, | 1559 public aura::client::ActivationChangeObserver, |
1557 public display::DisplayObserver { | 1560 public display::DisplayObserver { |
1558 public: | 1561 public: |
1559 WaylandRemoteShell(Display* display, | 1562 WaylandRemoteShell(Display* display, |
1560 int64_t display_id, | |
1561 wl_resource* remote_shell_resource) | 1563 wl_resource* remote_shell_resource) |
1562 : display_(display), | 1564 : display_(display), |
1563 display_id_(display_id), | |
1564 remote_shell_resource_(remote_shell_resource), | 1565 remote_shell_resource_(remote_shell_resource), |
1565 weak_ptr_factory_(this) { | 1566 weak_ptr_factory_(this) { |
1566 ash::WmShell::Get()->AddShellObserver(this); | 1567 ash::WmShell::Get()->AddShellObserver(this); |
1567 ash::Shell* shell = ash::Shell::GetInstance(); | 1568 ash::Shell* shell = ash::Shell::GetInstance(); |
1568 shell->activation_client()->AddObserver(this); | 1569 shell->activation_client()->AddObserver(this); |
1569 display::Screen::GetScreen()->AddObserver(this); | 1570 display::Screen::GetScreen()->AddObserver(this); |
1570 SendConfigure(); | 1571 |
1572 SendPrimaryDisplayMetrics(); | |
1571 SendActivated(shell->activation_client()->GetActiveWindow(), nullptr); | 1573 SendActivated(shell->activation_client()->GetActiveWindow(), nullptr); |
1572 } | 1574 } |
1573 ~WaylandRemoteShell() override { | 1575 ~WaylandRemoteShell() override { |
1574 ash::WmShell::Get()->RemoveShellObserver(this); | 1576 ash::WmShell::Get()->RemoveShellObserver(this); |
1575 ash::Shell::GetInstance()->activation_client()->RemoveObserver(this); | 1577 ash::Shell::GetInstance()->activation_client()->RemoveObserver(this); |
1576 display::Screen::GetScreen()->RemoveObserver(this); | 1578 display::Screen::GetScreen()->RemoveObserver(this); |
1577 } | 1579 } |
1578 | 1580 |
1579 std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface, | 1581 std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface, |
1580 int container) { | 1582 int container) { |
1581 return display_->CreateRemoteShellSurface(surface, container); | 1583 return display_->CreateRemoteShellSurface(surface, container); |
1582 } | 1584 } |
1583 | 1585 |
1584 std::unique_ptr<NotificationSurface> CreateNotificationSurface( | 1586 std::unique_ptr<NotificationSurface> CreateNotificationSurface( |
1585 Surface* surface, | 1587 Surface* surface, |
1586 const std::string& notification_id) { | 1588 const std::string& notification_id) { |
1587 return display_->CreateNotificationSurface(surface, notification_id); | 1589 return display_->CreateNotificationSurface(surface, notification_id); |
1588 } | 1590 } |
1589 | 1591 |
1590 // Overridden from display::DisplayObserver: | 1592 // Overridden from display::DisplayObserver: |
1591 void OnDisplayAdded(const display::Display& new_display) override {} | 1593 void OnDisplayAdded(const display::Display& new_display) override {} |
1592 void OnDisplayRemoved(const display::Display& new_display) override {} | 1594 void OnDisplayRemoved(const display::Display& new_display) override {} |
1593 void OnDisplayMetricsChanged(const display::Display& display, | 1595 void OnDisplayMetricsChanged(const display::Display& display, |
1594 uint32_t metrics) override { | 1596 uint32_t changed_metrics) override { |
1595 if (display.id() == display_id_) | 1597 if (display::Screen::GetScreen()->GetPrimaryDisplay().id() != display.id()) |
1596 SendConfigure(); | 1598 return; |
1599 | |
1600 if (changed_metrics & | |
1601 (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_DEVICE_SCALE_FACTOR | | |
1602 DISPLAY_METRIC_ROTATION | DISPLAY_METRIC_WORK_AREA)) { | |
1603 SendDisplayMetrics(display); | |
1604 } | |
1605 SendConfigure_DEPRECATED(display); | |
1597 } | 1606 } |
1598 | 1607 |
1599 // Overridden from ash::ShellObserver: | 1608 // Overridden from ash::ShellObserver: |
1600 void OnDisplayWorkAreaInsetsChanged() override { SendConfigure(); } | 1609 void OnDisplayWorkAreaInsetsChanged() override { |
1610 SendPrimaryDisplayMetrics(); | |
1611 } | |
oshima
2016/07/29 14:42:03
I'll put this back when I merge to 53.
| |
1601 void OnMaximizeModeStarted() override { | 1612 void OnMaximizeModeStarted() override { |
1602 SendLayoutModeChange(ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET); | 1613 layout_mode_ = ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET; |
1614 SendLayoutModeChange_DEPRECATED(); | |
1615 | |
1603 send_configure_after_layout_change_ = true; | 1616 send_configure_after_layout_change_ = true; |
1604 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 1617 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
1605 FROM_HERE, base::Bind(&WaylandRemoteShell::MaybeSendConfigure, | 1618 FROM_HERE, base::Bind(&WaylandRemoteShell::MaybeSendConfigure, |
1606 weak_ptr_factory_.GetWeakPtr()), | 1619 weak_ptr_factory_.GetWeakPtr()), |
1607 base::TimeDelta::FromMilliseconds(kConfigureDelayAfterLayoutSwitchMs)); | 1620 base::TimeDelta::FromMilliseconds(kConfigureDelayAfterLayoutSwitchMs)); |
1608 } | 1621 } |
1609 void OnMaximizeModeEnded() override { | 1622 void OnMaximizeModeEnded() override { |
1610 SendLayoutModeChange(ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED); | 1623 layout_mode_ = ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED; |
1624 SendLayoutModeChange_DEPRECATED(); | |
1611 send_configure_after_layout_change_ = true; | 1625 send_configure_after_layout_change_ = true; |
1612 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 1626 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
1613 FROM_HERE, base::Bind(&WaylandRemoteShell::MaybeSendConfigure, | 1627 FROM_HERE, base::Bind(&WaylandRemoteShell::MaybeSendConfigure, |
1614 weak_ptr_factory_.GetWeakPtr()), | 1628 weak_ptr_factory_.GetWeakPtr()), |
1615 base::TimeDelta::FromMilliseconds(kConfigureDelayAfterLayoutSwitchMs)); | 1629 base::TimeDelta::FromMilliseconds(kConfigureDelayAfterLayoutSwitchMs)); |
1616 } | 1630 } |
1617 | 1631 |
1618 // Overridden from aura::client::ActivationChangeObserver: | 1632 // Overridden from aura::client::ActivationChangeObserver: |
1619 void OnWindowActivated( | 1633 void OnWindowActivated( |
1620 aura::client::ActivationChangeObserver::ActivationReason reason, | 1634 aura::client::ActivationChangeObserver::ActivationReason reason, |
1621 aura::Window* gained_active, | 1635 aura::Window* gained_active, |
1622 aura::Window* lost_active) override { | 1636 aura::Window* lost_active) override { |
1623 SendActivated(gained_active, lost_active); | 1637 SendActivated(gained_active, lost_active); |
1624 } | 1638 } |
1625 | 1639 |
1626 private: | 1640 private: |
1641 void SendPrimaryDisplayMetrics() { | |
1642 const display::Display primary = | |
1643 display::Screen::GetScreen()->GetPrimaryDisplay(); | |
1644 | |
1645 SendConfigure_DEPRECATED(primary); | |
1646 SendDisplayMetrics(primary); | |
1647 } | |
1648 | |
1627 void MaybeSendConfigure() { | 1649 void MaybeSendConfigure() { |
1628 if (send_configure_after_layout_change_) | 1650 if (send_configure_after_layout_change_) |
1629 SendConfigure(); | 1651 SendPrimaryDisplayMetrics(); |
1630 } | 1652 } |
1631 | 1653 |
1632 void SendConfigure() { | 1654 void SendDisplayMetrics(const display::Display& display) { |
1655 if (wl_resource_get_version(remote_shell_resource_) < 9) | |
1656 return; | |
1657 | |
1633 send_configure_after_layout_change_ = false; | 1658 send_configure_after_layout_change_ = false; |
1634 const display::Display& display = | 1659 const ash::DisplayInfo& info = |
1635 ash::Shell::GetInstance()->display_manager()->GetDisplayForId( | 1660 ash::Shell::GetInstance()->display_manager()->GetDisplayInfo( |
1636 display_id_); | 1661 display.id()); |
1662 | |
1663 gfx::Insets work_area_insets = display.GetWorkAreaInsets(); | |
1664 gfx::Rect native_bounds = info.bounds_in_native(); | |
1665 | |
1666 int refresh_rate = 60000; | |
1667 zwp_remote_shell_v1_send_configuration_changed( | |
1668 remote_shell_resource_, | |
1669 native_bounds.width(), | |
1670 native_bounds.height(), | |
1671 wl_fixed_from_double(info.device_dpi()), | |
1672 OutputTransform(display.rotation()), | |
1673 refresh_rate, | |
1674 wl_fixed_from_double(display.device_scale_factor()), | |
1675 display.size().width(), display.size().height(), | |
1676 work_area_insets.left(), work_area_insets.top(), | |
1677 work_area_insets.right(), work_area_insets.bottom(), layout_mode_); | |
1678 | |
1679 wl_client_flush(wl_resource_get_client(remote_shell_resource_)); | |
1680 } | |
1681 | |
1682 void SendConfigure_DEPRECATED(const display::Display& display) { | |
1683 send_configure_after_layout_change_ = false; | |
1684 | |
1685 if (wl_resource_get_version(remote_shell_resource_) >= 9) | |
1686 return; | |
1687 | |
1637 gfx::Insets work_area_insets = display.GetWorkAreaInsets(); | 1688 gfx::Insets work_area_insets = display.GetWorkAreaInsets(); |
1638 zwp_remote_shell_v1_send_configure( | 1689 zwp_remote_shell_v1_send_configure( |
1639 remote_shell_resource_, display.size().width(), display.size().height(), | 1690 remote_shell_resource_, display.size().width(), display.size().height(), |
1640 work_area_insets.left(), work_area_insets.top(), | 1691 work_area_insets.left(), work_area_insets.top(), |
1641 work_area_insets.right(), work_area_insets.bottom()); | 1692 work_area_insets.right(), work_area_insets.bottom()); |
1642 wl_client_flush(wl_resource_get_client(remote_shell_resource_)); | 1693 wl_client_flush(wl_resource_get_client(remote_shell_resource_)); |
1643 } | 1694 } |
1644 | 1695 |
1645 void SendLayoutModeChange(uint32_t mode) { | 1696 void SendLayoutModeChange_DEPRECATED() { |
1646 if (wl_resource_get_version(remote_shell_resource_) < 8) | 1697 if (wl_resource_get_version(remote_shell_resource_) < 8) |
1647 return; | 1698 return; |
1648 zwp_remote_shell_v1_send_layout_mode_changed(remote_shell_resource_, mode); | 1699 zwp_remote_shell_v1_send_layout_mode_changed(remote_shell_resource_, |
1700 layout_mode_); | |
1649 wl_client_flush(wl_resource_get_client(remote_shell_resource_)); | 1701 wl_client_flush(wl_resource_get_client(remote_shell_resource_)); |
1650 } | 1702 } |
1651 | 1703 |
1652 void SendActivated(aura::Window* gained_active, aura::Window* lost_active) { | 1704 void SendActivated(aura::Window* gained_active, aura::Window* lost_active) { |
1653 Surface* gained_active_surface = | 1705 Surface* gained_active_surface = |
1654 gained_active ? ShellSurface::GetMainSurface(gained_active) : nullptr; | 1706 gained_active ? ShellSurface::GetMainSurface(gained_active) : nullptr; |
1655 Surface* lost_active_surface = | 1707 Surface* lost_active_surface = |
1656 lost_active ? ShellSurface::GetMainSurface(lost_active) : nullptr; | 1708 lost_active ? ShellSurface::GetMainSurface(lost_active) : nullptr; |
1657 wl_resource* gained_active_surface_resource = | 1709 wl_resource* gained_active_surface_resource = |
1658 gained_active_surface ? GetSurfaceResource(gained_active_surface) | 1710 gained_active_surface ? GetSurfaceResource(gained_active_surface) |
(...skipping 19 matching lines...) Expand all Loading... | |
1678 | 1730 |
1679 zwp_remote_shell_v1_send_activated(remote_shell_resource_, | 1731 zwp_remote_shell_v1_send_activated(remote_shell_resource_, |
1680 gained_active_surface_resource, | 1732 gained_active_surface_resource, |
1681 lost_active_surface_resource); | 1733 lost_active_surface_resource); |
1682 wl_client_flush(client); | 1734 wl_client_flush(client); |
1683 } | 1735 } |
1684 | 1736 |
1685 // The exo display instance. Not owned. | 1737 // The exo display instance. Not owned. |
1686 Display* const display_; | 1738 Display* const display_; |
1687 | 1739 |
1688 // The identifier associated with the observed display. | |
1689 const int64_t display_id_; | |
1690 | |
1691 // The remote shell resource associated with observer. | 1740 // The remote shell resource associated with observer. |
1692 wl_resource* const remote_shell_resource_; | 1741 wl_resource* const remote_shell_resource_; |
1693 | 1742 |
1694 bool send_configure_after_layout_change_ = false; | 1743 bool send_configure_after_layout_change_ = false; |
1695 | 1744 |
1745 int layout_mode_ = ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED; | |
1746 | |
1696 base::WeakPtrFactory<WaylandRemoteShell> weak_ptr_factory_; | 1747 base::WeakPtrFactory<WaylandRemoteShell> weak_ptr_factory_; |
1697 | 1748 |
1698 DISALLOW_COPY_AND_ASSIGN(WaylandRemoteShell); | 1749 DISALLOW_COPY_AND_ASSIGN(WaylandRemoteShell); |
1699 }; | 1750 }; |
1700 | 1751 |
1701 void remote_shell_destroy(wl_client* client, wl_resource* resource) { | 1752 void remote_shell_destroy(wl_client* client, wl_resource* resource) { |
1702 // Nothing to do here. | 1753 // Nothing to do here. |
1703 } | 1754 } |
1704 | 1755 |
1705 int RemoteSurfaceContainer(uint32_t container) { | 1756 int RemoteSurfaceContainer(uint32_t container) { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1831 wl_resource_get_version(resource), id); | 1882 wl_resource_get_version(resource), id); |
1832 SetImplementation(notification_surface_resource, | 1883 SetImplementation(notification_surface_resource, |
1833 ¬ification_surface_implementation, | 1884 ¬ification_surface_implementation, |
1834 std::move(notification_surface)); | 1885 std::move(notification_surface)); |
1835 } | 1886 } |
1836 | 1887 |
1837 const struct zwp_remote_shell_v1_interface remote_shell_implementation = { | 1888 const struct zwp_remote_shell_v1_interface remote_shell_implementation = { |
1838 remote_shell_destroy, remote_shell_get_remote_surface, | 1889 remote_shell_destroy, remote_shell_get_remote_surface, |
1839 remote_shell_get_notification_surface}; | 1890 remote_shell_get_notification_surface}; |
1840 | 1891 |
1841 const uint32_t remote_shell_version = 8; | 1892 const uint32_t remote_shell_version = 9; |
1842 | 1893 |
1843 void bind_remote_shell(wl_client* client, | 1894 void bind_remote_shell(wl_client* client, |
1844 void* data, | 1895 void* data, |
1845 uint32_t version, | 1896 uint32_t version, |
1846 uint32_t id) { | 1897 uint32_t id) { |
1847 wl_resource* resource = | 1898 wl_resource* resource = |
1848 wl_resource_create(client, &zwp_remote_shell_v1_interface, | 1899 wl_resource_create(client, &zwp_remote_shell_v1_interface, |
1849 std::min(version, remote_shell_version), id); | 1900 std::min(version, remote_shell_version), id); |
1850 | 1901 |
1851 // TODO(reveman): Multi-display support. | |
1852 const display::Display& display = ash::Shell::GetInstance() | |
1853 ->display_manager() | |
1854 ->GetPrimaryDisplayCandidate(); | |
1855 | |
1856 SetImplementation(resource, &remote_shell_implementation, | 1902 SetImplementation(resource, &remote_shell_implementation, |
1857 base::WrapUnique(new WaylandRemoteShell( | 1903 base::WrapUnique(new WaylandRemoteShell( |
1858 static_cast<Display*>(data), display.id(), resource))); | 1904 static_cast<Display*>(data), resource))); |
1859 } | 1905 } |
1860 | 1906 |
1861 //////////////////////////////////////////////////////////////////////////////// | 1907 //////////////////////////////////////////////////////////////////////////////// |
1862 // zwp_vsync_timing_v1_interface: | 1908 // zwp_vsync_timing_v1_interface: |
1863 | 1909 |
1864 // Implements VSync timing interface by monitoring a compositor for updates | 1910 // Implements VSync timing interface by monitoring a compositor for updates |
1865 // to VSync parameters. | 1911 // to VSync parameters. |
1866 class VSyncTiming : public ui::CompositorVSyncManager::Observer { | 1912 class VSyncTiming : public ui::CompositorVSyncManager::Observer { |
1867 public: | 1913 public: |
1868 ~VSyncTiming() { vsync_manager_->RemoveObserver(this); } | 1914 ~VSyncTiming() { vsync_manager_->RemoveObserver(this); } |
(...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2996 DCHECK(event_loop); | 3042 DCHECK(event_loop); |
2997 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); | 3043 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); |
2998 } | 3044 } |
2999 | 3045 |
3000 void Server::Flush() { | 3046 void Server::Flush() { |
3001 wl_display_flush_clients(wl_display_.get()); | 3047 wl_display_flush_clients(wl_display_.get()); |
3002 } | 3048 } |
3003 | 3049 |
3004 } // namespace wayland | 3050 } // namespace wayland |
3005 } // namespace exo | 3051 } // namespace exo |
OLD | NEW |