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 12 matching lines...) Expand all Loading... |
23 | 23 |
24 #include <algorithm> | 24 #include <algorithm> |
25 #include <cstdlib> | 25 #include <cstdlib> |
26 #include <iterator> | 26 #include <iterator> |
27 #include <string> | 27 #include <string> |
28 #include <utility> | 28 #include <utility> |
29 | 29 |
30 #include "ash/common/display/display_info.h" | 30 #include "ash/common/display/display_info.h" |
31 #include "ash/common/shell_observer.h" | 31 #include "ash/common/shell_observer.h" |
32 #include "ash/common/shell_window_ids.h" | 32 #include "ash/common/shell_window_ids.h" |
33 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | |
34 #include "ash/common/wm_shell.h" | |
35 #include "ash/display/display_manager.h" | |
36 #include "ash/shell.h" | 33 #include "ash/shell.h" |
37 #include "base/bind.h" | 34 #include "base/bind.h" |
38 #include "base/cancelable_callback.h" | 35 #include "base/cancelable_callback.h" |
39 #include "base/files/file_path.h" | 36 #include "base/files/file_path.h" |
40 #include "base/macros.h" | 37 #include "base/macros.h" |
41 #include "base/memory/free_deleter.h" | 38 #include "base/memory/free_deleter.h" |
42 #include "base/memory/ptr_util.h" | 39 #include "base/memory/ptr_util.h" |
43 #include "base/memory/weak_ptr.h" | 40 #include "base/memory/weak_ptr.h" |
44 #include "base/strings/stringprintf.h" | 41 #include "base/strings/stringprintf.h" |
45 #include "base/strings/utf_string_conversions.h" | 42 #include "base/strings/utf_string_conversions.h" |
(...skipping 10 matching lines...) Expand all Loading... |
56 #include "components/exo/pointer.h" | 53 #include "components/exo/pointer.h" |
57 #include "components/exo/pointer_delegate.h" | 54 #include "components/exo/pointer_delegate.h" |
58 #include "components/exo/pointer_stylus_delegate.h" | 55 #include "components/exo/pointer_stylus_delegate.h" |
59 #include "components/exo/shared_memory.h" | 56 #include "components/exo/shared_memory.h" |
60 #include "components/exo/shell_surface.h" | 57 #include "components/exo/shell_surface.h" |
61 #include "components/exo/sub_surface.h" | 58 #include "components/exo/sub_surface.h" |
62 #include "components/exo/surface.h" | 59 #include "components/exo/surface.h" |
63 #include "components/exo/surface_property.h" | 60 #include "components/exo/surface_property.h" |
64 #include "components/exo/touch.h" | 61 #include "components/exo/touch.h" |
65 #include "components/exo/touch_delegate.h" | 62 #include "components/exo/touch_delegate.h" |
| 63 #include "components/exo/wm_helper.h" |
66 #include "ipc/unix_domain_socket_util.h" | 64 #include "ipc/unix_domain_socket_util.h" |
67 #include "third_party/skia/include/core/SkRegion.h" | 65 #include "third_party/skia/include/core/SkRegion.h" |
68 #include "ui/aura/window_property.h" | 66 #include "ui/aura/window_property.h" |
69 #include "ui/base/hit_test.h" | 67 #include "ui/base/hit_test.h" |
70 #include "ui/compositor/compositor_vsync_manager.h" | 68 #include "ui/compositor/compositor_vsync_manager.h" |
71 #include "ui/display/display_observer.h" | 69 #include "ui/display/display_observer.h" |
72 #include "ui/display/screen.h" | 70 #include "ui/display/screen.h" |
73 #include "ui/events/keycodes/dom/keycode_converter.h" | 71 #include "ui/events/keycodes/dom/keycode_converter.h" |
74 #include "ui/gfx/buffer_format_util.h" | 72 #include "ui/gfx/buffer_format_util.h" |
75 #include "ui/gfx/buffer_types.h" | 73 #include "ui/gfx/buffer_types.h" |
76 #include "ui/views/widget/widget.h" | 74 #include "ui/views/widget/widget.h" |
77 #include "ui/views/widget/widget_observer.h" | 75 #include "ui/views/widget/widget_observer.h" |
78 #include "ui/wm/public/activation_change_observer.h" | |
79 #include "ui/wm/public/activation_client.h" | |
80 | 76 |
81 #if defined(USE_OZONE) | 77 #if defined(USE_OZONE) |
82 #include <drm_fourcc.h> | 78 #include <drm_fourcc.h> |
83 #include <linux-dmabuf-unstable-v1-server-protocol.h> | 79 #include <linux-dmabuf-unstable-v1-server-protocol.h> |
84 #include <wayland-drm-server-protocol.h> | 80 #include <wayland-drm-server-protocol.h> |
85 #endif | 81 #endif |
86 | 82 |
87 #if defined(USE_XKBCOMMON) | 83 #if defined(USE_XKBCOMMON) |
88 #include <xkbcommon/xkbcommon.h> | 84 #include <xkbcommon/xkbcommon.h> |
89 #include "ui/events/keycodes/scoped_xkb.h" // nogncheck | 85 #include "ui/events/keycodes/scoped_xkb.h" // nogncheck |
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1072 SendDisplayMetrics(); | 1068 SendDisplayMetrics(); |
1073 } | 1069 } |
1074 } | 1070 } |
1075 | 1071 |
1076 private: | 1072 private: |
1077 void SendDisplayMetrics() { | 1073 void SendDisplayMetrics() { |
1078 display::Display display = | 1074 display::Display display = |
1079 display::Screen::GetScreen()->GetPrimaryDisplay(); | 1075 display::Screen::GetScreen()->GetPrimaryDisplay(); |
1080 | 1076 |
1081 const ash::DisplayInfo& info = | 1077 const ash::DisplayInfo& info = |
1082 ash::Shell::GetInstance()->display_manager()->GetDisplayInfo( | 1078 WMHelper::GetInstance()->GetDisplayInfo(display.id()); |
1083 display.id()); | |
1084 | 1079 |
1085 const float kInchInMm = 25.4f; | 1080 const float kInchInMm = 25.4f; |
1086 const char* kUnknownMake = "unknown"; | 1081 const char* kUnknownMake = "unknown"; |
1087 const char* kUnknownModel = "unknown"; | 1082 const char* kUnknownModel = "unknown"; |
1088 | 1083 |
1089 gfx::Rect bounds = info.bounds_in_native(); | 1084 gfx::Rect bounds = info.bounds_in_native(); |
1090 wl_output_send_geometry( | 1085 wl_output_send_geometry( |
1091 output_resource_, bounds.x(), bounds.y(), | 1086 output_resource_, bounds.x(), bounds.y(), |
1092 static_cast<int>(kInchInMm * bounds.width() / info.device_dpi()), | 1087 static_cast<int>(kInchInMm * bounds.width() / info.device_dpi()), |
1093 static_cast<int>(kInchInMm * bounds.height() / info.device_dpi()), | 1088 static_cast<int>(kInchInMm * bounds.height() / info.device_dpi()), |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1566 } | 1561 } |
1567 | 1562 |
1568 const struct zwp_notification_surface_v1_interface | 1563 const struct zwp_notification_surface_v1_interface |
1569 notification_surface_implementation = {notification_surface_destroy}; | 1564 notification_surface_implementation = {notification_surface_destroy}; |
1570 | 1565 |
1571 //////////////////////////////////////////////////////////////////////////////// | 1566 //////////////////////////////////////////////////////////////////////////////// |
1572 // remote_shell_interface: | 1567 // remote_shell_interface: |
1573 | 1568 |
1574 // Implements remote shell interface and monitors workspace state needed | 1569 // Implements remote shell interface and monitors workspace state needed |
1575 // for the remote shell interface. | 1570 // for the remote shell interface. |
1576 class WaylandRemoteShell : public ash::ShellObserver, | 1571 class WaylandRemoteShell : public WMHelper::MaximizeModeObserver, |
1577 public aura::client::ActivationChangeObserver, | 1572 public WMHelper::ActivationObserver, |
1578 public display::DisplayObserver { | 1573 public display::DisplayObserver { |
1579 public: | 1574 public: |
1580 WaylandRemoteShell(Display* display, | 1575 WaylandRemoteShell(Display* display, |
1581 wl_resource* remote_shell_resource) | 1576 wl_resource* remote_shell_resource) |
1582 : display_(display), | 1577 : display_(display), |
1583 remote_shell_resource_(remote_shell_resource), | 1578 remote_shell_resource_(remote_shell_resource), |
1584 weak_ptr_factory_(this) { | 1579 weak_ptr_factory_(this) { |
1585 ash::WmShell::Get()->AddShellObserver(this); | 1580 auto* helper = WMHelper::GetInstance(); |
1586 ash::Shell* shell = ash::Shell::GetInstance(); | 1581 helper->AddMaximizeModeObserver(this); |
1587 shell->activation_client()->AddObserver(this); | 1582 helper->AddActivationObserver(this); |
1588 display::Screen::GetScreen()->AddObserver(this); | 1583 display::Screen::GetScreen()->AddObserver(this); |
1589 | 1584 |
1590 layout_mode_ = ash::WmShell::Get() | 1585 layout_mode_ = helper->IsMaximizeModeWindowManagerEnabled() |
1591 ->maximize_mode_controller() | |
1592 ->IsMaximizeModeWindowManagerEnabled() | |
1593 ? ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET | 1586 ? ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET |
1594 : ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED; | 1587 : ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED; |
1595 | 1588 |
1596 SendPrimaryDisplayMetrics(); | 1589 SendPrimaryDisplayMetrics(); |
1597 SendActivated(shell->activation_client()->GetActiveWindow(), nullptr); | 1590 SendActivated(helper->GetActiveWindow(), nullptr); |
1598 } | 1591 } |
1599 ~WaylandRemoteShell() override { | 1592 ~WaylandRemoteShell() override { |
1600 ash::WmShell::Get()->RemoveShellObserver(this); | 1593 auto* helper = WMHelper::GetInstance(); |
1601 ash::Shell::GetInstance()->activation_client()->RemoveObserver(this); | 1594 helper->RemoveMaximizeModeObserver(this); |
| 1595 helper->RemoveActivationObserver(this); |
1602 display::Screen::GetScreen()->RemoveObserver(this); | 1596 display::Screen::GetScreen()->RemoveObserver(this); |
1603 } | 1597 } |
1604 | 1598 |
1605 std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface, | 1599 std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface, |
1606 int container) { | 1600 int container) { |
1607 return display_->CreateRemoteShellSurface(surface, container); | 1601 return display_->CreateRemoteShellSurface(surface, container); |
1608 } | 1602 } |
1609 | 1603 |
1610 std::unique_ptr<NotificationSurface> CreateNotificationSurface( | 1604 std::unique_ptr<NotificationSurface> CreateNotificationSurface( |
1611 Surface* surface, | 1605 Surface* surface, |
(...skipping 13 matching lines...) Expand all Loading... |
1625 // change. See WaylandPrimaryDisplayObserver::OnDisplayMetricsChanged | 1619 // change. See WaylandPrimaryDisplayObserver::OnDisplayMetricsChanged |
1626 // for more details. | 1620 // for more details. |
1627 if (changed_metrics & | 1621 if (changed_metrics & |
1628 (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_DEVICE_SCALE_FACTOR | | 1622 (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_DEVICE_SCALE_FACTOR | |
1629 DISPLAY_METRIC_ROTATION | DISPLAY_METRIC_WORK_AREA)) { | 1623 DISPLAY_METRIC_ROTATION | DISPLAY_METRIC_WORK_AREA)) { |
1630 SendDisplayMetrics(display); | 1624 SendDisplayMetrics(display); |
1631 } | 1625 } |
1632 SendConfigure_DEPRECATED(display); | 1626 SendConfigure_DEPRECATED(display); |
1633 } | 1627 } |
1634 | 1628 |
1635 // Overridden from ash::ShellObserver: | 1629 // Overridden from WMHelper::MaximizeModeObserver: |
1636 void OnMaximizeModeStarted() override { | 1630 void OnMaximizeModeStarted() override { |
1637 layout_mode_ = ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET; | 1631 layout_mode_ = ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET; |
1638 SendLayoutModeChange_DEPRECATED(); | 1632 SendLayoutModeChange_DEPRECATED(); |
1639 | 1633 |
1640 send_configure_after_layout_change_ = true; | 1634 send_configure_after_layout_change_ = true; |
1641 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 1635 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
1642 FROM_HERE, base::Bind(&WaylandRemoteShell::MaybeSendConfigure, | 1636 FROM_HERE, base::Bind(&WaylandRemoteShell::MaybeSendConfigure, |
1643 weak_ptr_factory_.GetWeakPtr()), | 1637 weak_ptr_factory_.GetWeakPtr()), |
1644 base::TimeDelta::FromMilliseconds(kConfigureDelayAfterLayoutSwitchMs)); | 1638 base::TimeDelta::FromMilliseconds(kConfigureDelayAfterLayoutSwitchMs)); |
1645 } | 1639 } |
1646 void OnMaximizeModeEnded() override { | 1640 void OnMaximizeModeEnded() override { |
1647 layout_mode_ = ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED; | 1641 layout_mode_ = ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED; |
1648 SendLayoutModeChange_DEPRECATED(); | 1642 SendLayoutModeChange_DEPRECATED(); |
1649 send_configure_after_layout_change_ = true; | 1643 send_configure_after_layout_change_ = true; |
1650 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 1644 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
1651 FROM_HERE, base::Bind(&WaylandRemoteShell::MaybeSendConfigure, | 1645 FROM_HERE, base::Bind(&WaylandRemoteShell::MaybeSendConfigure, |
1652 weak_ptr_factory_.GetWeakPtr()), | 1646 weak_ptr_factory_.GetWeakPtr()), |
1653 base::TimeDelta::FromMilliseconds(kConfigureDelayAfterLayoutSwitchMs)); | 1647 base::TimeDelta::FromMilliseconds(kConfigureDelayAfterLayoutSwitchMs)); |
1654 } | 1648 } |
1655 | 1649 |
1656 // Overridden from aura::client::ActivationChangeObserver: | 1650 // Overridden from WMHelper::ActivationObserver: |
1657 void OnWindowActivated( | 1651 void OnWindowActivated( |
1658 aura::client::ActivationChangeObserver::ActivationReason reason, | |
1659 aura::Window* gained_active, | 1652 aura::Window* gained_active, |
1660 aura::Window* lost_active) override { | 1653 aura::Window* lost_active) override { |
1661 SendActivated(gained_active, lost_active); | 1654 SendActivated(gained_active, lost_active); |
1662 } | 1655 } |
1663 | 1656 |
1664 private: | 1657 private: |
1665 void SendPrimaryDisplayMetrics() { | 1658 void SendPrimaryDisplayMetrics() { |
1666 const display::Display primary = | 1659 const display::Display primary = |
1667 display::Screen::GetScreen()->GetPrimaryDisplay(); | 1660 display::Screen::GetScreen()->GetPrimaryDisplay(); |
1668 | 1661 |
(...skipping 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3133 DCHECK(event_loop); | 3126 DCHECK(event_loop); |
3134 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); | 3127 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); |
3135 } | 3128 } |
3136 | 3129 |
3137 void Server::Flush() { | 3130 void Server::Flush() { |
3138 wl_display_flush_clients(wl_display_.get()); | 3131 wl_display_flush_clients(wl_display_.get()); |
3139 } | 3132 } |
3140 | 3133 |
3141 } // namespace wayland | 3134 } // namespace wayland |
3142 } // namespace exo | 3135 } // namespace exo |
OLD | NEW |