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 24 matching lines...) Expand all Loading... | |
35 #include "base/files/file_path.h" | 35 #include "base/files/file_path.h" |
36 #include "base/macros.h" | 36 #include "base/macros.h" |
37 #include "base/memory/free_deleter.h" | 37 #include "base/memory/free_deleter.h" |
38 #include "base/memory/ptr_util.h" | 38 #include "base/memory/ptr_util.h" |
39 #include "base/strings/stringprintf.h" | 39 #include "base/strings/stringprintf.h" |
40 #include "base/strings/utf_string_conversions.h" | 40 #include "base/strings/utf_string_conversions.h" |
41 #include "components/exo/buffer.h" | 41 #include "components/exo/buffer.h" |
42 #include "components/exo/display.h" | 42 #include "components/exo/display.h" |
43 #include "components/exo/keyboard.h" | 43 #include "components/exo/keyboard.h" |
44 #include "components/exo/keyboard_delegate.h" | 44 #include "components/exo/keyboard_delegate.h" |
45 #include "components/exo/notification_surface.h" | |
46 #include "components/exo/notification_surface_registry.h" | |
45 #include "components/exo/pointer.h" | 47 #include "components/exo/pointer.h" |
46 #include "components/exo/pointer_delegate.h" | 48 #include "components/exo/pointer_delegate.h" |
47 #include "components/exo/shared_memory.h" | 49 #include "components/exo/shared_memory.h" |
48 #include "components/exo/shell_surface.h" | 50 #include "components/exo/shell_surface.h" |
49 #include "components/exo/sub_surface.h" | 51 #include "components/exo/sub_surface.h" |
50 #include "components/exo/surface.h" | 52 #include "components/exo/surface.h" |
51 #include "components/exo/surface_property.h" | 53 #include "components/exo/surface_property.h" |
52 #include "components/exo/touch.h" | 54 #include "components/exo/touch.h" |
53 #include "components/exo/touch_delegate.h" | 55 #include "components/exo/touch_delegate.h" |
54 #include "ipc/unix_domain_socket_util.h" | 56 #include "ipc/unix_domain_socket_util.h" |
(...skipping 1423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1478 remote_surface_set_scale, | 1480 remote_surface_set_scale, |
1479 remote_surface_fullscreen, | 1481 remote_surface_fullscreen, |
1480 remote_surface_maximize, | 1482 remote_surface_maximize, |
1481 remote_surface_minimize, | 1483 remote_surface_minimize, |
1482 remote_surface_restore, | 1484 remote_surface_restore, |
1483 remote_surface_pin, | 1485 remote_surface_pin, |
1484 remote_surface_unpin, | 1486 remote_surface_unpin, |
1485 remote_surface_unfullscreen}; | 1487 remote_surface_unfullscreen}; |
1486 | 1488 |
1487 //////////////////////////////////////////////////////////////////////////////// | 1489 //////////////////////////////////////////////////////////////////////////////// |
1490 // notification_surface_interface: | |
1491 | |
1492 void notification_surface_destroy(wl_client* client, wl_resource* resource) { | |
1493 wl_resource_destroy(resource); | |
1494 } | |
1495 | |
1496 const struct zwp_notification_surface_v1_interface | |
1497 notification_surface_implementation = {notification_surface_destroy}; | |
1498 | |
1499 //////////////////////////////////////////////////////////////////////////////// | |
1488 // remote_shell_interface: | 1500 // remote_shell_interface: |
1489 | 1501 |
1490 // Implements remote shell interface and monitors workspace state needed | 1502 // Implements remote shell interface and monitors workspace state needed |
1491 // for the remote shell interface. | 1503 // for the remote shell interface. |
1492 class WaylandRemoteShell : public ash::ShellObserver, | 1504 class WaylandRemoteShell : public ash::ShellObserver, |
1493 public aura::client::ActivationChangeObserver, | 1505 public aura::client::ActivationChangeObserver, |
1494 public display::DisplayObserver { | 1506 public display::DisplayObserver { |
1495 public: | 1507 public: |
1496 WaylandRemoteShell(Display* display, | 1508 WaylandRemoteShell(Display* display, |
1497 int64_t display_id, | 1509 int64_t display_id, |
(...skipping 12 matching lines...) Expand all Loading... | |
1510 ash::WmShell::Get()->RemoveShellObserver(this); | 1522 ash::WmShell::Get()->RemoveShellObserver(this); |
1511 ash::Shell::GetInstance()->activation_client()->RemoveObserver(this); | 1523 ash::Shell::GetInstance()->activation_client()->RemoveObserver(this); |
1512 display::Screen::GetScreen()->RemoveObserver(this); | 1524 display::Screen::GetScreen()->RemoveObserver(this); |
1513 } | 1525 } |
1514 | 1526 |
1515 std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface, | 1527 std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface, |
1516 int container) { | 1528 int container) { |
1517 return display_->CreateRemoteShellSurface(surface, container); | 1529 return display_->CreateRemoteShellSurface(surface, container); |
1518 } | 1530 } |
1519 | 1531 |
1532 bool IsValidNotificationId(const std::string& notification_id) const { | |
reveman
2016/06/22 16:44:30
Would be nice if this could instead be validated w
xiyuan
2016/06/23 14:46:43
Done.
| |
1533 return display_->notification_surface_registry()->GetSurface( | |
1534 notification_id) == nullptr; | |
1535 } | |
1536 | |
1537 std::unique_ptr<NotificationSurface> CreateNotificationSurface( | |
1538 Surface* surface, | |
1539 const std::string& notification_id) { | |
1540 return display_->CreateNotificationSurface(surface, notification_id); | |
1541 } | |
1542 | |
1520 // Overridden from display::DisplayObserver: | 1543 // Overridden from display::DisplayObserver: |
1521 void OnDisplayAdded(const display::Display& new_display) override {} | 1544 void OnDisplayAdded(const display::Display& new_display) override {} |
1522 void OnDisplayRemoved(const display::Display& new_display) override {} | 1545 void OnDisplayRemoved(const display::Display& new_display) override {} |
1523 void OnDisplayMetricsChanged(const display::Display& display, | 1546 void OnDisplayMetricsChanged(const display::Display& display, |
1524 uint32_t metrics) override { | 1547 uint32_t metrics) override { |
1525 if (display.id() == display_id_) | 1548 if (display.id() == display_id_) |
1526 SendConfigure(); | 1549 SendConfigure(); |
1527 } | 1550 } |
1528 | 1551 |
1529 // Overridden from ash::ShellObserver: | 1552 // Overridden from ash::ShellObserver: |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1685 base::Bind(&HandleRemoteSurfaceCloseCallback, | 1708 base::Bind(&HandleRemoteSurfaceCloseCallback, |
1686 base::Unretained(remote_surface_resource))); | 1709 base::Unretained(remote_surface_resource))); |
1687 shell_surface->set_state_changed_callback( | 1710 shell_surface->set_state_changed_callback( |
1688 base::Bind(&HandleRemoteSurfaceStateChangedCallback, | 1711 base::Bind(&HandleRemoteSurfaceStateChangedCallback, |
1689 base::Unretained(remote_surface_resource))); | 1712 base::Unretained(remote_surface_resource))); |
1690 | 1713 |
1691 SetImplementation(remote_surface_resource, &remote_surface_implementation, | 1714 SetImplementation(remote_surface_resource, &remote_surface_implementation, |
1692 std::move(shell_surface)); | 1715 std::move(shell_surface)); |
1693 } | 1716 } |
1694 | 1717 |
1718 void remote_shell_get_notification_surface(wl_client* client, | |
1719 wl_resource* resource, | |
1720 uint32_t id, | |
1721 wl_resource* surface, | |
1722 const char* notification_id) { | |
1723 WaylandRemoteShell* remote_shell = | |
1724 GetUserDataAs<WaylandRemoteShell>(resource); | |
1725 if (!remote_shell->IsValidNotificationId(notification_id)) { | |
1726 wl_resource_post_error(resource, | |
1727 ZWP_REMOTE_SHELL_V1_ERROR_INVALID_NOTIFICATION_ID, | |
1728 "invalid notification id"); | |
1729 return; | |
1730 } | |
1731 | |
1732 std::unique_ptr<NotificationSurface> notification_surface = | |
1733 remote_shell->CreateNotificationSurface(GetUserDataAs<Surface>(surface), | |
1734 std::string(notification_id)); | |
1735 if (!notification_surface) { | |
reveman
2016/06/22 16:44:31
Instead of using a null return value here. Can you
xiyuan
2016/06/23 14:46:43
Done.
| |
1736 wl_resource_post_error(resource, ZWP_REMOTE_SHELL_V1_ERROR_ROLE, | |
1737 "surface has already been assigned a role"); | |
1738 return; | |
1739 } | |
1740 | |
1741 wl_resource* notification_surface_resource = | |
1742 wl_resource_create(client, &zwp_notification_surface_v1_interface, | |
1743 wl_resource_get_version(resource), id); | |
1744 SetImplementation(notification_surface_resource, | |
1745 ¬ification_surface_implementation, | |
1746 std::move(notification_surface)); | |
1747 } | |
1748 | |
1695 const struct zwp_remote_shell_v1_interface remote_shell_implementation = { | 1749 const struct zwp_remote_shell_v1_interface remote_shell_implementation = { |
1696 remote_shell_destroy, remote_shell_get_remote_surface}; | 1750 remote_shell_destroy, remote_shell_get_remote_surface, |
1751 remote_shell_get_notification_surface}; | |
1697 | 1752 |
1698 const uint32_t remote_shell_version = 3; | 1753 const uint32_t remote_shell_version = 4; |
1699 | 1754 |
1700 void bind_remote_shell(wl_client* client, | 1755 void bind_remote_shell(wl_client* client, |
1701 void* data, | 1756 void* data, |
1702 uint32_t version, | 1757 uint32_t version, |
1703 uint32_t id) { | 1758 uint32_t id) { |
1704 wl_resource* resource = | 1759 wl_resource* resource = |
1705 wl_resource_create(client, &zwp_remote_shell_v1_interface, | 1760 wl_resource_create(client, &zwp_remote_shell_v1_interface, |
1706 std::min(version, remote_shell_version), id); | 1761 std::min(version, remote_shell_version), id); |
1707 | 1762 |
1708 // TODO(reveman): Multi-display support. | 1763 // TODO(reveman): Multi-display support. |
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2739 DCHECK(event_loop); | 2794 DCHECK(event_loop); |
2740 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); | 2795 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); |
2741 } | 2796 } |
2742 | 2797 |
2743 void Server::Flush() { | 2798 void Server::Flush() { |
2744 wl_display_flush_clients(wl_display_.get()); | 2799 wl_display_flush_clients(wl_display_.get()); |
2745 } | 2800 } |
2746 | 2801 |
2747 } // namespace wayland | 2802 } // namespace wayland |
2748 } // namespace exo | 2803 } // namespace exo |
OLD | NEW |