Chromium Code Reviews| 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_manager.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 std::unique_ptr<NotificationSurface> CreateNotificationSurface( | |
| 1533 Surface* surface, | |
| 1534 const std::string& notification_id) { | |
| 1535 return display_->CreateNotificationSurface(surface, notification_id); | |
| 1536 } | |
| 1537 | |
| 1520 // Overridden from display::DisplayObserver: | 1538 // Overridden from display::DisplayObserver: |
| 1521 void OnDisplayAdded(const display::Display& new_display) override {} | 1539 void OnDisplayAdded(const display::Display& new_display) override {} |
| 1522 void OnDisplayRemoved(const display::Display& new_display) override {} | 1540 void OnDisplayRemoved(const display::Display& new_display) override {} |
| 1523 void OnDisplayMetricsChanged(const display::Display& display, | 1541 void OnDisplayMetricsChanged(const display::Display& display, |
| 1524 uint32_t metrics) override { | 1542 uint32_t metrics) override { |
| 1525 if (display.id() == display_id_) | 1543 if (display.id() == display_id_) |
| 1526 SendConfigure(); | 1544 SendConfigure(); |
| 1527 } | 1545 } |
| 1528 | 1546 |
| 1529 // Overridden from ash::ShellObserver: | 1547 // Overridden from ash::ShellObserver: |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1685 base::Bind(&HandleRemoteSurfaceCloseCallback, | 1703 base::Bind(&HandleRemoteSurfaceCloseCallback, |
| 1686 base::Unretained(remote_surface_resource))); | 1704 base::Unretained(remote_surface_resource))); |
| 1687 shell_surface->set_state_changed_callback( | 1705 shell_surface->set_state_changed_callback( |
| 1688 base::Bind(&HandleRemoteSurfaceStateChangedCallback, | 1706 base::Bind(&HandleRemoteSurfaceStateChangedCallback, |
| 1689 base::Unretained(remote_surface_resource))); | 1707 base::Unretained(remote_surface_resource))); |
| 1690 | 1708 |
| 1691 SetImplementation(remote_surface_resource, &remote_surface_implementation, | 1709 SetImplementation(remote_surface_resource, &remote_surface_implementation, |
| 1692 std::move(shell_surface)); | 1710 std::move(shell_surface)); |
| 1693 } | 1711 } |
| 1694 | 1712 |
| 1713 void remote_shell_get_notification_surface(wl_client* client, | |
| 1714 wl_resource* resource, | |
| 1715 uint32_t id, | |
| 1716 wl_resource* surface, | |
| 1717 const char* notification_id) { | |
| 1718 if (GetUserDataAs<Surface>(surface)->HasSurfaceDelegate()) { | |
| 1719 wl_resource_post_error(resource, ZWP_REMOTE_SHELL_V1_ERROR_ROLE, | |
| 1720 "surface has already been assigned a role"); | |
| 1721 return; | |
| 1722 } | |
| 1723 | |
| 1724 std::unique_ptr<NotificationSurface> notification_surface = | |
| 1725 GetUserDataAs<WaylandRemoteShell>(resource)->CreateNotificationSurface( | |
| 1726 GetUserDataAs<Surface>(surface), std::string(notification_id)); | |
| 1727 if (!notification_surface) { | |
| 1728 wl_resource_post_error(resource, | |
| 1729 ZWP_REMOTE_SHELL_V1_ERROR_INVALID_NOTIFICATION_ID, | |
| 1730 "invalid notification id"); | |
| 1731 return; | |
| 1732 } | |
| 1733 | |
| 1734 wl_resource* notification_surface_resource = | |
| 1735 wl_resource_create(client, &zwp_notification_surface_v1_interface, | |
| 1736 wl_resource_get_version(resource), id); | |
| 1737 SetImplementation(notification_surface_resource, | |
| 1738 ¬ification_surface_implementation, | |
| 1739 std::move(notification_surface)); | |
| 1740 } | |
| 1741 | |
| 1695 const struct zwp_remote_shell_v1_interface remote_shell_implementation = { | 1742 const struct zwp_remote_shell_v1_interface remote_shell_implementation = { |
| 1696 remote_shell_destroy, remote_shell_get_remote_surface}; | 1743 remote_shell_destroy, remote_shell_get_remote_surface, |
| 1744 remote_shell_get_notification_surface}; | |
| 1697 | 1745 |
| 1698 const uint32_t remote_shell_version = 3; | 1746 const uint32_t remote_shell_version = 4; |
|
reveman
2016/06/23 16:34:53
Note: I think this will be 6 after rebase
xiyuan
2016/06/23 17:46:10
will rebase and fix it in next PS.
| |
| 1699 | 1747 |
| 1700 void bind_remote_shell(wl_client* client, | 1748 void bind_remote_shell(wl_client* client, |
| 1701 void* data, | 1749 void* data, |
| 1702 uint32_t version, | 1750 uint32_t version, |
| 1703 uint32_t id) { | 1751 uint32_t id) { |
| 1704 wl_resource* resource = | 1752 wl_resource* resource = |
| 1705 wl_resource_create(client, &zwp_remote_shell_v1_interface, | 1753 wl_resource_create(client, &zwp_remote_shell_v1_interface, |
| 1706 std::min(version, remote_shell_version), id); | 1754 std::min(version, remote_shell_version), id); |
| 1707 | 1755 |
| 1708 // TODO(reveman): Multi-display support. | 1756 // TODO(reveman): Multi-display support. |
| (...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2739 DCHECK(event_loop); | 2787 DCHECK(event_loop); |
| 2740 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); | 2788 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); |
| 2741 } | 2789 } |
| 2742 | 2790 |
| 2743 void Server::Flush() { | 2791 void Server::Flush() { |
| 2744 wl_display_flush_clients(wl_display_.get()); | 2792 wl_display_flush_clients(wl_display_.get()); |
| 2745 } | 2793 } |
| 2746 | 2794 |
| 2747 } // namespace wayland | 2795 } // namespace wayland |
| 2748 } // namespace exo | 2796 } // namespace exo |
| OLD | NEW |