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

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: add NotificationServiceRegistry to track notification surface 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
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 23 matching lines...) Expand all
34 #include "base/files/file_path.h" 34 #include "base/files/file_path.h"
35 #include "base/macros.h" 35 #include "base/macros.h"
36 #include "base/memory/free_deleter.h" 36 #include "base/memory/free_deleter.h"
37 #include "base/memory/ptr_util.h" 37 #include "base/memory/ptr_util.h"
38 #include "base/strings/stringprintf.h" 38 #include "base/strings/stringprintf.h"
39 #include "base/strings/utf_string_conversions.h" 39 #include "base/strings/utf_string_conversions.h"
40 #include "components/exo/buffer.h" 40 #include "components/exo/buffer.h"
41 #include "components/exo/display.h" 41 #include "components/exo/display.h"
42 #include "components/exo/keyboard.h" 42 #include "components/exo/keyboard.h"
43 #include "components/exo/keyboard_delegate.h" 43 #include "components/exo/keyboard_delegate.h"
44 #include "components/exo/notification_surface.h"
44 #include "components/exo/pointer.h" 45 #include "components/exo/pointer.h"
45 #include "components/exo/pointer_delegate.h" 46 #include "components/exo/pointer_delegate.h"
46 #include "components/exo/shared_memory.h" 47 #include "components/exo/shared_memory.h"
47 #include "components/exo/shell_surface.h" 48 #include "components/exo/shell_surface.h"
48 #include "components/exo/sub_surface.h" 49 #include "components/exo/sub_surface.h"
49 #include "components/exo/surface.h" 50 #include "components/exo/surface.h"
50 #include "components/exo/touch.h" 51 #include "components/exo/touch.h"
51 #include "components/exo/touch_delegate.h" 52 #include "components/exo/touch_delegate.h"
52 #include "ipc/unix_domain_socket_util.h" 53 #include "ipc/unix_domain_socket_util.h"
53 #include "third_party/skia/include/core/SkRegion.h" 54 #include "third_party/skia/include/core/SkRegion.h"
(...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 remote_surface_set_scale, 1485 remote_surface_set_scale,
1485 remote_surface_fullscreen, 1486 remote_surface_fullscreen,
1486 remote_surface_maximize, 1487 remote_surface_maximize,
1487 remote_surface_minimize, 1488 remote_surface_minimize,
1488 remote_surface_restore, 1489 remote_surface_restore,
1489 remote_surface_pin, 1490 remote_surface_pin,
1490 remote_surface_unpin, 1491 remote_surface_unpin,
1491 remote_surface_unfullscreen}; 1492 remote_surface_unfullscreen};
1492 1493
1493 //////////////////////////////////////////////////////////////////////////////// 1494 ////////////////////////////////////////////////////////////////////////////////
1495 // notification_surface_interface:
1496
1497 void notification_surface_destroy(wl_client* client, wl_resource* resource) {
1498 wl_resource_destroy(resource);
1499 }
1500
1501 const struct zwp_notification_surface_v1_interface
1502 notification_surface_implementation = {notification_surface_destroy};
1503
1504 ////////////////////////////////////////////////////////////////////////////////
1494 // remote_shell_interface: 1505 // remote_shell_interface:
1495 1506
1496 // Implements remote shell interface and monitors workspace state needed 1507 // Implements remote shell interface and monitors workspace state needed
1497 // for the remote shell interface. 1508 // for the remote shell interface.
1498 class WaylandRemoteShell : public ash::ShellObserver, 1509 class WaylandRemoteShell : public ash::ShellObserver,
1499 public aura::client::ActivationChangeObserver, 1510 public aura::client::ActivationChangeObserver,
1500 public display::DisplayObserver { 1511 public display::DisplayObserver {
1501 public: 1512 public:
1502 WaylandRemoteShell(Display* display, 1513 WaylandRemoteShell(Display* display,
1503 int64_t display_id, 1514 int64_t display_id,
(...skipping 12 matching lines...) Expand all
1516 ash::WmShell::Get()->RemoveShellObserver(this); 1527 ash::WmShell::Get()->RemoveShellObserver(this);
1517 ash::Shell::GetInstance()->activation_client()->RemoveObserver(this); 1528 ash::Shell::GetInstance()->activation_client()->RemoveObserver(this);
1518 display::Screen::GetScreen()->RemoveObserver(this); 1529 display::Screen::GetScreen()->RemoveObserver(this);
1519 } 1530 }
1520 1531
1521 std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface, 1532 std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface,
1522 int container) { 1533 int container) {
1523 return display_->CreateRemoteShellSurface(surface, container); 1534 return display_->CreateRemoteShellSurface(surface, container);
1524 } 1535 }
1525 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
1526 // Overridden from display::DisplayObserver: 1543 // Overridden from display::DisplayObserver:
1527 void OnDisplayAdded(const display::Display& new_display) override {} 1544 void OnDisplayAdded(const display::Display& new_display) override {}
1528 void OnDisplayRemoved(const display::Display& new_display) override {} 1545 void OnDisplayRemoved(const display::Display& new_display) override {}
1529 void OnDisplayMetricsChanged(const display::Display& display, 1546 void OnDisplayMetricsChanged(const display::Display& display,
1530 uint32_t metrics) override { 1547 uint32_t metrics) override {
1531 if (display.id() == display_id_) 1548 if (display.id() == display_id_)
1532 SendConfigure(); 1549 SendConfigure();
1533 } 1550 }
1534 1551
1535 // Overridden from ash::ShellObserver: 1552 // Overridden from ash::ShellObserver:
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 base::Bind(&HandleRemoteSurfaceCloseCallback, 1700 base::Bind(&HandleRemoteSurfaceCloseCallback,
1684 base::Unretained(remote_surface_resource))); 1701 base::Unretained(remote_surface_resource)));
1685 shell_surface->set_state_changed_callback( 1702 shell_surface->set_state_changed_callback(
1686 base::Bind(&HandleRemoteSurfaceStateChangedCallback, 1703 base::Bind(&HandleRemoteSurfaceStateChangedCallback,
1687 base::Unretained(remote_surface_resource))); 1704 base::Unretained(remote_surface_resource)));
1688 1705
1689 SetImplementation(remote_surface_resource, &remote_surface_implementation, 1706 SetImplementation(remote_surface_resource, &remote_surface_implementation,
1690 std::move(shell_surface)); 1707 std::move(shell_surface));
1691 } 1708 }
1692 1709
1710 void remote_shell_get_notification_surface(wl_client* client,
1711 wl_resource* resource,
1712 uint32_t id,
1713 wl_resource* surface,
1714 const char* notification_id) {
1715 std::unique_ptr<NotificationSurface> notification_surface =
1716 GetUserDataAs<WaylandRemoteShell>(resource)->CreateNotificationSurface(
1717 GetUserDataAs<Surface>(surface), std::string(notification_id));
1718 DCHECK(notification_surface);
reveman 2016/06/16 03:35:20 what can cause this to fail? fyi, if the client ca
xiyuan 2016/06/20 22:40:29 Replaced with notification id validating and role
1719
1720 wl_resource* notification_surface_resource =
1721 wl_resource_create(client, &zwp_notification_surface_v1_interface,
1722 wl_resource_get_version(resource), id);
1723 SetImplementation(notification_surface_resource,
1724 &notification_surface_implementation,
1725 std::move(notification_surface));
1726 }
1727
1693 const struct zwp_remote_shell_v1_interface remote_shell_implementation = { 1728 const struct zwp_remote_shell_v1_interface remote_shell_implementation = {
1694 remote_shell_destroy, remote_shell_get_remote_surface}; 1729 remote_shell_destroy, remote_shell_get_remote_surface,
1730 remote_shell_get_notification_surface};
1695 1731
1696 const uint32_t remote_shell_version = 3; 1732 const uint32_t remote_shell_version = 4;
1697 1733
1698 void bind_remote_shell(wl_client* client, 1734 void bind_remote_shell(wl_client* client,
1699 void* data, 1735 void* data,
1700 uint32_t version, 1736 uint32_t version,
1701 uint32_t id) { 1737 uint32_t id) {
1702 wl_resource* resource = 1738 wl_resource* resource =
1703 wl_resource_create(client, &zwp_remote_shell_v1_interface, 1739 wl_resource_create(client, &zwp_remote_shell_v1_interface,
1704 std::min(version, remote_shell_version), id); 1740 std::min(version, remote_shell_version), id);
1705 1741
1706 // TODO(reveman): Multi-display support. 1742 // TODO(reveman): Multi-display support.
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
2649 DCHECK(event_loop); 2685 DCHECK(event_loop);
2650 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); 2686 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds());
2651 } 2687 }
2652 2688
2653 void Server::Flush() { 2689 void Server::Flush() {
2654 wl_display_flush_clients(wl_display_.get()); 2690 wl_display_flush_clients(wl_display_.get());
2655 } 2691 }
2656 2692
2657 } // namespace wayland 2693 } // namespace wayland
2658 } // namespace exo 2694 } // namespace exo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698