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

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

Issue 2061023002: wayland: Fix GetUserDataAs in remote_shell_get_remote_surface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 | « no previous file | 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 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 remote_surface_maximize, 1486 remote_surface_maximize,
1487 remote_surface_minimize, 1487 remote_surface_minimize,
1488 remote_surface_restore, 1488 remote_surface_restore,
1489 remote_surface_pin, 1489 remote_surface_pin,
1490 remote_surface_unpin, 1490 remote_surface_unpin,
1491 remote_surface_unfullscreen}; 1491 remote_surface_unfullscreen};
1492 1492
1493 //////////////////////////////////////////////////////////////////////////////// 1493 ////////////////////////////////////////////////////////////////////////////////
1494 // remote_shell_interface: 1494 // remote_shell_interface:
1495 1495
1496 // Observer class that monitors workspace state needed to implement the 1496 // Implements remote shell interface and monitors workspace state needed
1497 // remote shell interface. 1497 // for the remote shell interface.
1498 class WaylandWorkspaceObserver : public ash::ShellObserver, 1498 class WaylandRemoteShell : public ash::ShellObserver,
1499 public aura::client::ActivationChangeObserver, 1499 public aura::client::ActivationChangeObserver,
1500 public display::DisplayObserver { 1500 public display::DisplayObserver {
1501 public: 1501 public:
1502 WaylandWorkspaceObserver(const display::Display& display, 1502 WaylandRemoteShell(Display* exo_display,
reveman 2016/06/13 21:44:56 nit: s/exo_display/display/
xiyuan 2016/06/13 22:08:09 Done.
1503 wl_resource* remote_shell_resource) 1503 const display::Display& display,
reveman 2016/06/13 21:44:56 nit: s/const display::Display& display/int64_t dis
xiyuan 2016/06/13 22:08:09 Done.
1504 : display_id_(display.id()), 1504 wl_resource* remote_shell_resource)
1505 : exo_display_(exo_display),
reveman 2016/06/13 21:44:56 nit: display_(display)
xiyuan 2016/06/13 22:08:09 Done.
1506 display_id_(display.id()),
1505 remote_shell_resource_(remote_shell_resource) { 1507 remote_shell_resource_(remote_shell_resource) {
1506 ash::WmShell::Get()->AddShellObserver(this); 1508 ash::WmShell::Get()->AddShellObserver(this);
1507 ash::Shell* shell = ash::Shell::GetInstance(); 1509 ash::Shell* shell = ash::Shell::GetInstance();
1508 shell->activation_client()->AddObserver(this); 1510 shell->activation_client()->AddObserver(this);
1509 display::Screen::GetScreen()->AddObserver(this); 1511 display::Screen::GetScreen()->AddObserver(this);
1510 SendConfigure(); 1512 SendConfigure();
1511 SendActivated(shell->activation_client()->GetActiveWindow(), nullptr); 1513 SendActivated(shell->activation_client()->GetActiveWindow(), nullptr);
1512 } 1514 }
1513 ~WaylandWorkspaceObserver() override { 1515 ~WaylandRemoteShell() override {
1514 ash::WmShell::Get()->RemoveShellObserver(this); 1516 ash::WmShell::Get()->RemoveShellObserver(this);
1515 ash::Shell::GetInstance()->activation_client()->RemoveObserver(this); 1517 ash::Shell::GetInstance()->activation_client()->RemoveObserver(this);
1516 display::Screen::GetScreen()->RemoveObserver(this); 1518 display::Screen::GetScreen()->RemoveObserver(this);
1517 } 1519 }
1518 1520
1521 std::unique_ptr<ShellSurface> CreateRemoteShellSurface(Surface* surface,
reveman 2016/06/13 21:44:56 nit: "Remote" could be removed from the name here
xiyuan 2016/06/13 22:08:09 Done.
1522 int container) {
1523 return exo_display_->CreateRemoteShellSurface(surface, container);
1524 }
1525
1519 // Overridden from display::DisplayObserver: 1526 // Overridden from display::DisplayObserver:
1520 void OnDisplayAdded(const display::Display& new_display) override {} 1527 void OnDisplayAdded(const display::Display& new_display) override {}
1521 void OnDisplayRemoved(const display::Display& new_display) override {} 1528 void OnDisplayRemoved(const display::Display& new_display) override {}
1522 void OnDisplayMetricsChanged(const display::Display& display, 1529 void OnDisplayMetricsChanged(const display::Display& display,
1523 uint32_t metrics) override { 1530 uint32_t metrics) override {
1524 if (display.id() == display_id_) 1531 if (display.id() == display_id_)
1525 SendConfigure(); 1532 SendConfigure();
1526 } 1533 }
1527 1534
1528 // Overridden from ash::ShellObserver: 1535 // Overridden from ash::ShellObserver:
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1575 wl_resource_get_client(lost_active_surface_resource) != client) { 1582 wl_resource_get_client(lost_active_surface_resource) != client) {
1576 lost_active_surface_resource = nullptr; 1583 lost_active_surface_resource = nullptr;
1577 } 1584 }
1578 1585
1579 zwp_remote_shell_v1_send_activated(remote_shell_resource_, 1586 zwp_remote_shell_v1_send_activated(remote_shell_resource_,
1580 gained_active_surface_resource, 1587 gained_active_surface_resource,
1581 lost_active_surface_resource); 1588 lost_active_surface_resource);
1582 wl_client_flush(client); 1589 wl_client_flush(client);
1583 } 1590 }
1584 1591
1592 // The exo display instance. Not owned.
1593 Display* const exo_display_;
reveman 2016/06/13 21:44:56 nit: s/exo_display_/display_/
xiyuan 2016/06/13 22:08:09 Done.
1594
1585 // The identifier associated with the observed display. 1595 // The identifier associated with the observed display.
1586 int64_t display_id_; 1596 int64_t display_id_;
1587 1597
1588 // The remote shell resource associated with observer. 1598 // The remote shell resource associated with observer.
1589 wl_resource* const remote_shell_resource_; 1599 wl_resource* const remote_shell_resource_;
1590 1600
1591 DISALLOW_COPY_AND_ASSIGN(WaylandWorkspaceObserver); 1601 DISALLOW_COPY_AND_ASSIGN(WaylandRemoteShell);
1592 }; 1602 };
1593 1603
1594 void remote_shell_destroy(wl_client* client, wl_resource* resource) { 1604 void remote_shell_destroy(wl_client* client, wl_resource* resource) {
1595 // Nothing to do here. 1605 // Nothing to do here.
1596 } 1606 }
1597 1607
1598 int RemoteSurfaceContainer(uint32_t container) { 1608 int RemoteSurfaceContainer(uint32_t container) {
1599 switch (container) { 1609 switch (container) {
1600 case ZWP_REMOTE_SHELL_V1_CONTAINER_DEFAULT: 1610 case ZWP_REMOTE_SHELL_V1_CONTAINER_DEFAULT:
1601 return ash::kShellWindowId_DefaultContainer; 1611 return ash::kShellWindowId_DefaultContainer;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1650 } 1660 }
1651 wl_client_flush(wl_resource_get_client(resource)); 1661 wl_client_flush(wl_resource_get_client(resource));
1652 } 1662 }
1653 1663
1654 void remote_shell_get_remote_surface(wl_client* client, 1664 void remote_shell_get_remote_surface(wl_client* client,
1655 wl_resource* resource, 1665 wl_resource* resource,
1656 uint32_t id, 1666 uint32_t id,
1657 wl_resource* surface, 1667 wl_resource* surface,
1658 uint32_t container) { 1668 uint32_t container) {
1659 std::unique_ptr<ShellSurface> shell_surface = 1669 std::unique_ptr<ShellSurface> shell_surface =
1660 GetUserDataAs<Display>(resource)->CreateRemoteShellSurface( 1670 GetUserDataAs<WaylandRemoteShell>(resource)->CreateRemoteShellSurface(
1661 GetUserDataAs<Surface>(surface), RemoteSurfaceContainer(container)); 1671 GetUserDataAs<Surface>(surface), RemoteSurfaceContainer(container));
1662 if (!shell_surface) { 1672 if (!shell_surface) {
1663 wl_resource_post_error(resource, ZWP_REMOTE_SHELL_V1_ERROR_ROLE, 1673 wl_resource_post_error(resource, ZWP_REMOTE_SHELL_V1_ERROR_ROLE,
1664 "surface has already been assigned a role"); 1674 "surface has already been assigned a role");
1665 return; 1675 return;
1666 } 1676 }
1667 1677
1668 wl_resource* remote_surface_resource = 1678 wl_resource* remote_surface_resource =
1669 wl_resource_create(client, &zwp_remote_surface_v1_interface, 1679 wl_resource_create(client, &zwp_remote_surface_v1_interface,
1670 wl_resource_get_version(resource), id); 1680 wl_resource_get_version(resource), id);
(...skipping 20 matching lines...) Expand all
1691 uint32_t id) { 1701 uint32_t id) {
1692 wl_resource* resource = 1702 wl_resource* resource =
1693 wl_resource_create(client, &zwp_remote_shell_v1_interface, 1703 wl_resource_create(client, &zwp_remote_shell_v1_interface,
1694 std::min(version, remote_shell_version), id); 1704 std::min(version, remote_shell_version), id);
1695 1705
1696 // TODO(reveman): Multi-display support. 1706 // TODO(reveman): Multi-display support.
1697 const display::Display& display = ash::Shell::GetInstance() 1707 const display::Display& display = ash::Shell::GetInstance()
1698 ->display_manager() 1708 ->display_manager()
1699 ->GetPrimaryDisplayCandidate(); 1709 ->GetPrimaryDisplayCandidate();
1700 1710
1701 SetImplementation( 1711 SetImplementation(resource, &remote_shell_implementation,
1702 resource, &remote_shell_implementation, 1712 base::WrapUnique(new WaylandRemoteShell(
1703 base::WrapUnique(new WaylandWorkspaceObserver(display, resource))); 1713 static_cast<Display*>(data), display, resource)));
1704 } 1714 }
1705 1715
1706 //////////////////////////////////////////////////////////////////////////////// 1716 ////////////////////////////////////////////////////////////////////////////////
1707 // wl_data_device_interface: 1717 // wl_data_device_interface:
1708 1718
1709 void data_device_start_drag(wl_client* client, 1719 void data_device_start_drag(wl_client* client,
1710 wl_resource* resource, 1720 wl_resource* resource,
1711 wl_resource* source_resource, 1721 wl_resource* source_resource,
1712 wl_resource* origin_resource, 1722 wl_resource* origin_resource,
1713 wl_resource* icon_resource, 1723 wl_resource* icon_resource,
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
2639 DCHECK(event_loop); 2649 DCHECK(event_loop);
2640 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); 2650 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds());
2641 } 2651 }
2642 2652
2643 void Server::Flush() { 2653 void Server::Flush() {
2644 wl_display_flush_clients(wl_display_.get()); 2654 wl_display_flush_clients(wl_display_.get());
2645 } 2655 }
2646 2656
2647 } // namespace wayland 2657 } // namespace wayland
2648 } // namespace exo 2658 } // namespace exo
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698