Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Side by Side Diff: components/exo/wayland/server.cc

Issue 2065133002: exo: Implement notification surface support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@notification-wayland-protocol
Patch Set: fix compile Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/exo/notification_surface_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 25 matching lines...) Expand all
36 #include "base/files/file_path.h" 36 #include "base/files/file_path.h"
37 #include "base/macros.h" 37 #include "base/macros.h"
38 #include "base/memory/free_deleter.h" 38 #include "base/memory/free_deleter.h"
39 #include "base/memory/ptr_util.h" 39 #include "base/memory/ptr_util.h"
40 #include "base/strings/stringprintf.h" 40 #include "base/strings/stringprintf.h"
41 #include "base/strings/utf_string_conversions.h" 41 #include "base/strings/utf_string_conversions.h"
42 #include "components/exo/buffer.h" 42 #include "components/exo/buffer.h"
43 #include "components/exo/display.h" 43 #include "components/exo/display.h"
44 #include "components/exo/keyboard.h" 44 #include "components/exo/keyboard.h"
45 #include "components/exo/keyboard_delegate.h" 45 #include "components/exo/keyboard_delegate.h"
46 #include "components/exo/notification_surface.h"
47 #include "components/exo/notification_surface_manager.h"
46 #include "components/exo/pointer.h" 48 #include "components/exo/pointer.h"
47 #include "components/exo/pointer_delegate.h" 49 #include "components/exo/pointer_delegate.h"
48 #include "components/exo/shared_memory.h" 50 #include "components/exo/shared_memory.h"
49 #include "components/exo/shell_surface.h" 51 #include "components/exo/shell_surface.h"
50 #include "components/exo/sub_surface.h" 52 #include "components/exo/sub_surface.h"
51 #include "components/exo/surface.h" 53 #include "components/exo/surface.h"
52 #include "components/exo/surface_property.h" 54 #include "components/exo/surface_property.h"
53 #include "components/exo/touch.h" 55 #include "components/exo/touch.h"
54 #include "components/exo/touch_delegate.h" 56 #include "components/exo/touch_delegate.h"
55 #include "ipc/unix_domain_socket_util.h" 57 #include "ipc/unix_domain_socket_util.h"
(...skipping 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 remote_surface_minimize, 1507 remote_surface_minimize,
1506 remote_surface_restore, 1508 remote_surface_restore,
1507 remote_surface_pin, 1509 remote_surface_pin,
1508 remote_surface_unpin, 1510 remote_surface_unpin,
1509 remote_surface_unfullscreen, 1511 remote_surface_unfullscreen,
1510 remote_surface_set_rectangular_shadow, 1512 remote_surface_set_rectangular_shadow,
1511 remote_surface_set_title, 1513 remote_surface_set_title,
1512 remote_surface_set_top_inset}; 1514 remote_surface_set_top_inset};
1513 1515
1514 //////////////////////////////////////////////////////////////////////////////// 1516 ////////////////////////////////////////////////////////////////////////////////
1517 // notification_surface_interface:
1518
1519 void notification_surface_destroy(wl_client* client, wl_resource* resource) {
1520 wl_resource_destroy(resource);
1521 }
1522
1523 const struct zwp_notification_surface_v1_interface
1524 notification_surface_implementation = {notification_surface_destroy};
1525
1526 ////////////////////////////////////////////////////////////////////////////////
1515 // remote_shell_interface: 1527 // remote_shell_interface:
1516 1528
1517 // Implements remote shell interface and monitors workspace state needed 1529 // Implements remote shell interface and monitors workspace state needed
1518 // for the remote shell interface. 1530 // for the remote shell interface.
1519 class WaylandRemoteShell : public ash::ShellObserver, 1531 class WaylandRemoteShell : public ash::ShellObserver,
1520 public aura::client::ActivationChangeObserver, 1532 public aura::client::ActivationChangeObserver,
1521 public display::DisplayObserver { 1533 public display::DisplayObserver {
1522 public: 1534 public:
1523 WaylandRemoteShell(Display* display, 1535 WaylandRemoteShell(Display* display,
1524 int64_t display_id, 1536 int64_t display_id,
(...skipping 12 matching lines...) Expand all
1537 ash::WmShell::Get()->RemoveShellObserver(this); 1549 ash::WmShell::Get()->RemoveShellObserver(this);
1538 ash::Shell::GetInstance()->activation_client()->RemoveObserver(this); 1550 ash::Shell::GetInstance()->activation_client()->RemoveObserver(this);
1539 display::Screen::GetScreen()->RemoveObserver(this); 1551 display::Screen::GetScreen()->RemoveObserver(this);
1540 } 1552 }
1541 1553
1542 std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface, 1554 std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface,
1543 int container) { 1555 int container) {
1544 return display_->CreateRemoteShellSurface(surface, container); 1556 return display_->CreateRemoteShellSurface(surface, container);
1545 } 1557 }
1546 1558
1559 std::unique_ptr<NotificationSurface> CreateNotificationSurface(
1560 Surface* surface,
1561 const std::string& notification_id) {
1562 return display_->CreateNotificationSurface(surface, notification_id);
1563 }
1564
1547 // Overridden from display::DisplayObserver: 1565 // Overridden from display::DisplayObserver:
1548 void OnDisplayAdded(const display::Display& new_display) override {} 1566 void OnDisplayAdded(const display::Display& new_display) override {}
1549 void OnDisplayRemoved(const display::Display& new_display) override {} 1567 void OnDisplayRemoved(const display::Display& new_display) override {}
1550 void OnDisplayMetricsChanged(const display::Display& display, 1568 void OnDisplayMetricsChanged(const display::Display& display,
1551 uint32_t metrics) override { 1569 uint32_t metrics) override {
1552 if (display.id() == display_id_) 1570 if (display.id() == display_id_)
1553 SendConfigure(); 1571 SendConfigure();
1554 } 1572 }
1555 1573
1556 // Overridden from ash::ShellObserver: 1574 // Overridden from ash::ShellObserver:
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 base::Bind(&HandleRemoteSurfaceCloseCallback, 1730 base::Bind(&HandleRemoteSurfaceCloseCallback,
1713 base::Unretained(remote_surface_resource))); 1731 base::Unretained(remote_surface_resource)));
1714 shell_surface->set_state_changed_callback( 1732 shell_surface->set_state_changed_callback(
1715 base::Bind(&HandleRemoteSurfaceStateChangedCallback, 1733 base::Bind(&HandleRemoteSurfaceStateChangedCallback,
1716 base::Unretained(remote_surface_resource))); 1734 base::Unretained(remote_surface_resource)));
1717 1735
1718 SetImplementation(remote_surface_resource, &remote_surface_implementation, 1736 SetImplementation(remote_surface_resource, &remote_surface_implementation,
1719 std::move(shell_surface)); 1737 std::move(shell_surface));
1720 } 1738 }
1721 1739
1740 void remote_shell_get_notification_surface(wl_client* client,
1741 wl_resource* resource,
1742 uint32_t id,
1743 wl_resource* surface,
1744 const char* notification_id) {
1745 if (GetUserDataAs<Surface>(surface)->HasSurfaceDelegate()) {
1746 wl_resource_post_error(resource, ZWP_REMOTE_SHELL_V1_ERROR_ROLE,
1747 "surface has already been assigned a role");
1748 return;
1749 }
1750
1751 std::unique_ptr<NotificationSurface> notification_surface =
1752 GetUserDataAs<WaylandRemoteShell>(resource)->CreateNotificationSurface(
1753 GetUserDataAs<Surface>(surface), std::string(notification_id));
1754 if (!notification_surface) {
1755 wl_resource_post_error(resource,
1756 ZWP_REMOTE_SHELL_V1_ERROR_INVALID_NOTIFICATION_ID,
1757 "invalid notification id");
1758 return;
1759 }
1760
1761 wl_resource* notification_surface_resource =
1762 wl_resource_create(client, &zwp_notification_surface_v1_interface,
1763 wl_resource_get_version(resource), id);
1764 SetImplementation(notification_surface_resource,
1765 &notification_surface_implementation,
1766 std::move(notification_surface));
1767 }
1768
1722 const struct zwp_remote_shell_v1_interface remote_shell_implementation = { 1769 const struct zwp_remote_shell_v1_interface remote_shell_implementation = {
1723 remote_shell_destroy, remote_shell_get_remote_surface}; 1770 remote_shell_destroy, remote_shell_get_remote_surface,
1771 remote_shell_get_notification_surface};
1724 1772
1725 const uint32_t remote_shell_version = 5; 1773 const uint32_t remote_shell_version = 6;
1726 1774
1727 void bind_remote_shell(wl_client* client, 1775 void bind_remote_shell(wl_client* client,
1728 void* data, 1776 void* data,
1729 uint32_t version, 1777 uint32_t version,
1730 uint32_t id) { 1778 uint32_t id) {
1731 wl_resource* resource = 1779 wl_resource* resource =
1732 wl_resource_create(client, &zwp_remote_shell_v1_interface, 1780 wl_resource_create(client, &zwp_remote_shell_v1_interface,
1733 std::min(version, remote_shell_version), id); 1781 std::min(version, remote_shell_version), id);
1734 1782
1735 // TODO(reveman): Multi-display support. 1783 // TODO(reveman): Multi-display support.
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after
2787 DCHECK(event_loop); 2835 DCHECK(event_loop);
2788 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); 2836 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds());
2789 } 2837 }
2790 2838
2791 void Server::Flush() { 2839 void Server::Flush() {
2792 wl_display_flush_clients(wl_display_.get()); 2840 wl_display_flush_clients(wl_display_.get());
2793 } 2841 }
2794 2842
2795 } // namespace wayland 2843 } // namespace wayland
2796 } // namespace exo 2844 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/notification_surface_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698