0

window-service: rename ServerWindow to ProxyWindow

And use the name 'proxy' in more places.

BUG=none
TEST=none

Change-Id: I84309d4fd898b9571df8b78e756ae02f54dcbd8a
Reviewed-on: https://chromium-review.googlesource.com/c/1377184
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#616752}
This commit is contained in:
Scott Violet
2018-12-14 18:29:15 +00:00
committed by Commit Bot
parent fd8ad21305
commit 25848c1f22
32 changed files with 463 additions and 471 deletions

@@ -88,7 +88,7 @@ void PrintWindowHierarchy(ws::WindowService* window_service,
const gfx::Vector2dF& subpixel_position_offset = const gfx::Vector2dF& subpixel_position_offset =
window->layer()->subpixel_position_offset(); window->layer()->subpixel_position_offset();
*out << indent_str; *out << indent_str;
if (window_service && ws::WindowService::HasRemoteClient(window)) if (window_service && ws::WindowService::IsProxyWindow(window))
*out << " [proxy] id=" << window_service->GetIdForDebugging(window) << " "; *out << " [proxy] id=" << window_service->GetIdForDebugging(window) << " ";
*out << name << " (" << window << ")" *out << name << " (" << window << ")"
<< " type=" << window->type(); << " type=" << window->type();

@@ -223,7 +223,7 @@ bool AshWindowTreeHostPlatform::ShouldSendKeyEventToIme() {
// Don't send key events to IME if they are going to go to a remote client. // Don't send key events to IME if they are going to go to a remote client.
// Remote clients handle forwarding to IME (as necessary). // Remote clients handle forwarding to IME (as necessary).
aura::Window* target = window()->targeter()->FindTargetForKeyEvent(window()); aura::Window* target = window()->targeter()->FindTargetForKeyEvent(window());
return !target || !ws::WindowService::HasRemoteClient(target); return !target || !ws::WindowService::IsProxyWindow(target);
} }
void AshWindowTreeHostPlatform::SetTextInputState( void AshWindowTreeHostPlatform::SetTextInputState(

@@ -25,17 +25,17 @@ ImeFocusHandler::~ImeFocusHandler() {
void ImeFocusHandler::OnWindowFocused(aura::Window* gained_focus, void ImeFocusHandler::OnWindowFocused(aura::Window* gained_focus,
aura::Window* lost_focus) { aura::Window* lost_focus) {
const bool client_window_gaining_focus = const bool proxy_window_gaining_focus =
ws::WindowService::HasRemoteClient(gained_focus); ws::WindowService::IsProxyWindow(gained_focus);
const bool client_window_losing_focus = const bool proxy_window_losing_focus =
ws::WindowService::HasRemoteClient(lost_focus); ws::WindowService::IsProxyWindow(lost_focus);
// Focus moves to a ClientWindow from an ash window. // Focus moves to a ProxyWindow from an ash window.
if (client_window_gaining_focus && !client_window_losing_focus) if (proxy_window_gaining_focus && !proxy_window_losing_focus)
input_method_->OnBlur(); input_method_->OnBlur();
// Focus moves to an ash window from a ClientWindow. // Focus moves to an ash window from a ProxyWindow.
if (!client_window_gaining_focus && client_window_losing_focus) if (!proxy_window_gaining_focus && proxy_window_losing_focus)
input_method_->OnFocus(); input_method_->OnFocus();
} }

@@ -8,7 +8,7 @@
#include "ash/laser/laser_pointer_view.h" #include "ash/laser/laser_pointer_view.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "services/ws/server_window.h" #include "services/ws/proxy_window.h"
#include "ui/events/test/event_generator.h" #include "ui/events/test/event_generator.h"
namespace ash { namespace ash {
@@ -158,11 +158,10 @@ TEST_F(LaserPointerControllerTest, LaserPointerPrediction) {
TEST_F(LaserPointerControllerTest, LaserPointerWorksWithRemoteApp) { TEST_F(LaserPointerControllerTest, LaserPointerWorksWithRemoteApp) {
std::unique_ptr<aura::Window> window = std::unique_ptr<aura::Window> window =
CreateTestWindow(gfx::Rect(50, 50, 100, 100)); CreateTestWindow(gfx::Rect(50, 50, 100, 100));
ws::ServerWindow* server_window = ws::ProxyWindow* proxy_window = ws::ProxyWindow::GetMayBeNull(window.get());
ws::ServerWindow::GetMayBeNull(window.get()); ASSERT_TRUE(proxy_window);
ASSERT_TRUE(server_window);
// Setting the client area triggers slightly different logic. // Setting the client area triggers slightly different logic.
server_window->SetClientArea(gfx::Insets(10), std::vector<gfx::Rect>()); proxy_window->SetClientArea(gfx::Insets(10), std::vector<gfx::Rect>());
// The laser pointer mode only works with stylus. // The laser pointer mode only works with stylus.
ui::test::EventGenerator* event_generator = GetEventGenerator(); ui::test::EventGenerator* event_generator = GetEventGenerator();

@@ -384,8 +384,8 @@ bool Shell::IsSystemModalWindowOpen() {
} }
// static // static
bool Shell::HasRemoteClient(aura::Window* window) { bool Shell::IsProxyWindow(aura::Window* window) {
return ws::WindowService::HasRemoteClient(window); return ws::WindowService::IsProxyWindow(window);
} }
// static // static

@@ -267,9 +267,10 @@ class ASH_EXPORT Shell : public SessionObserver,
// Returns true if a system-modal dialog window is currently open. // Returns true if a system-modal dialog window is currently open.
static bool IsSystemModalWindowOpen(); static bool IsSystemModalWindowOpen();
// Whether |window| hosts a remote client (e.g. the keyboard shortcut viewer // Returns true if |window| is a proxy window. A proxy window is a window that
// app under classic ash, or a browser window under mash). // was created by way of a WindowService client (e.g. the keyboard shortcut
static bool HasRemoteClient(aura::Window* window); // viewer app under classic ash, or a browser window under mash).
static bool IsProxyWindow(aura::Window* window);
// Registers all ash related local state prefs to the given |registry|. // Registers all ash related local state prefs to the given |registry|.
static void RegisterLocalStatePrefs(PrefRegistrySimple* registry, static void RegisterLocalStatePrefs(PrefRegistrySimple* registry,

@@ -73,7 +73,7 @@ bool IsTopLevelWindow(aura::Window* window) {
!window->delegate()) { !window->delegate()) {
return false; return false;
} }
if (ws::WindowService::HasRemoteClient(window)) if (ws::WindowService::IsProxyWindow(window))
return ws::WindowService::IsTopLevelWindow(window); return ws::WindowService::IsTopLevelWindow(window);
return true; return true;
} }

@@ -23,7 +23,7 @@ bool IsTopLevelWindow(aura::Window* window) {
// ui::LAYER_TEXTURED is for non-mash environment. For Mash, browser windows // ui::LAYER_TEXTURED is for non-mash environment. For Mash, browser windows
// are not with LAYER_TEXTURED but have a remote client. // are not with LAYER_TEXTURED but have a remote client.
return window->layer()->type() == ui::LAYER_TEXTURED || return window->layer()->type() == ui::LAYER_TEXTURED ||
ws::WindowService::HasRemoteClient(window); ws::WindowService::IsProxyWindow(window);
} }
// Returns true if |window| can be a target at |screen_point| by |targeter|. // Returns true if |window| can be a target at |screen_point| by |targeter|.

@@ -28,7 +28,7 @@ ws::Id GetTransportId(aura::Window* window) {
} // namespace } // namespace
bool IsProxyWindow(aura::Window* window) { bool IsProxyWindow(aura::Window* window) {
return ws::WindowService::HasRemoteClient(window); return ws::WindowService::IsProxyWindow(window);
} }
aura::Window* GetProxyWindowForClientWindow(aura::Window* window) { aura::Window* GetProxyWindowForClientWindow(aura::Window* window) {

@@ -52,12 +52,12 @@ component("lib") {
"host_event_queue.cc", "host_event_queue.cc",
"injected_event_handler.cc", "injected_event_handler.cc",
"injected_event_handler.h", "injected_event_handler.h",
"proxy_window.cc",
"proxy_window.h",
"remoting_event_injector.cc", "remoting_event_injector.cc",
"remoting_event_injector.h", "remoting_event_injector.h",
"screen_provider.cc", "screen_provider.cc",
"screen_provider.h", "screen_provider.h",
"server_window.cc",
"server_window.h",
"topmost_window_observer.cc", "topmost_window_observer.cc",
"topmost_window_observer.h", "topmost_window_observer.h",
"user_activity_monitor.cc", "user_activity_monitor.cc",
@@ -133,8 +133,8 @@ static_library("test_support") {
"event_queue_test_helper.h", "event_queue_test_helper.h",
"event_test_utils.cc", "event_test_utils.cc",
"event_test_utils.h", "event_test_utils.h",
"server_window_test_helper.cc", "proxy_window_test_helper.cc",
"server_window_test_helper.h", "proxy_window_test_helper.h",
"test_change_tracker.cc", "test_change_tracker.cc",
"test_change_tracker.h", "test_change_tracker.h",
"test_host_event_dispatcher.cc", "test_host_event_dispatcher.cc",
@@ -213,8 +213,8 @@ source_set("tests") {
"event_queue_unittest.cc", "event_queue_unittest.cc",
"focus_handler_unittest.cc", "focus_handler_unittest.cc",
"injected_event_handler_unittest.cc", "injected_event_handler_unittest.cc",
"proxy_window_unittest.cc",
"screen_provider_unittest.cc", "screen_provider_unittest.cc",
"server_window_unittest.cc",
"topmost_window_observer_unittest.cc", "topmost_window_observer_unittest.cc",
"user_activity_monitor_unittest.cc", "user_activity_monitor_unittest.cc",
"window_delegate_impl_unittest.cc", "window_delegate_impl_unittest.cc",

@@ -10,7 +10,7 @@
#include "components/viz/host/host_frame_sink_manager.h" #include "components/viz/host/host_frame_sink_manager.h"
#include "services/ws/client_change.h" #include "services/ws/client_change.h"
#include "services/ws/client_change_tracker.h" #include "services/ws/client_change_tracker.h"
#include "services/ws/server_window.h" #include "services/ws/proxy_window.h"
#include "services/ws/window_service.h" #include "services/ws/window_service.h"
#include "services/ws/window_tree.h" #include "services/ws/window_tree.h"
#include "ui/aura/client/screen_position_client.h" #include "ui/aura/client/screen_position_client.h"
@@ -47,15 +47,14 @@ ClientRoot::ClientRoot(WindowTree* window_tree,
} }
ClientRoot::~ClientRoot() { ClientRoot::~ClientRoot() {
ServerWindow* server_window = ServerWindow::GetMayBeNull(window_); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window_);
window_->RemoveObserver(this); window_->RemoveObserver(this);
if (window_->GetHost()) if (window_->GetHost())
window_->GetHost()->RemoveObserver(this); window_->GetHost()->RemoveObserver(this);
viz::HostFrameSinkManager* host_frame_sink_manager = viz::HostFrameSinkManager* host_frame_sink_manager =
window_->env()->context_factory_private()->GetHostFrameSinkManager(); window_->env()->context_factory_private()->GetHostFrameSinkManager();
host_frame_sink_manager->InvalidateFrameSinkId( host_frame_sink_manager->InvalidateFrameSinkId(proxy_window->frame_sink_id());
server_window->frame_sink_id());
} }
void ClientRoot::SetClientAreaInsets(const gfx::Insets& client_area_insets) { void ClientRoot::SetClientAreaInsets(const gfx::Insets& client_area_insets) {
@@ -70,7 +69,7 @@ void ClientRoot::RegisterVizEmbeddingSupport() {
viz::HostFrameSinkManager* host_frame_sink_manager = viz::HostFrameSinkManager* host_frame_sink_manager =
window_->env()->context_factory_private()->GetHostFrameSinkManager(); window_->env()->context_factory_private()->GetHostFrameSinkManager();
viz::FrameSinkId frame_sink_id = viz::FrameSinkId frame_sink_id =
ServerWindow::GetMayBeNull(window_)->frame_sink_id(); ProxyWindow::GetMayBeNull(window_)->frame_sink_id();
host_frame_sink_manager->RegisterFrameSinkId( host_frame_sink_manager->RegisterFrameSinkId(
frame_sink_id, this, viz::ReportFirstSurfaceActivation::kYes); frame_sink_id, this, viz::ReportFirstSurfaceActivation::kYes);
window_->SetEmbedFrameSinkId(frame_sink_id); window_->SetEmbedFrameSinkId(frame_sink_id);
@@ -83,8 +82,8 @@ bool ClientRoot::ShouldAssignLocalSurfaceId() {
// WindowService. First level embeddings have no embeddings above them. // WindowService. First level embeddings have no embeddings above them.
if (is_top_level_) if (is_top_level_)
return true; return true;
ServerWindow* server_window = ServerWindow::GetMayBeNull(window_); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window_);
return server_window->owning_window_tree() == nullptr; return proxy_window->owning_window_tree() == nullptr;
} }
void ClientRoot::UpdateLocalSurfaceIdIfNecessary() { void ClientRoot::UpdateLocalSurfaceIdIfNecessary() {
@@ -93,14 +92,14 @@ void ClientRoot::UpdateLocalSurfaceIdIfNecessary() {
gfx::Size size_in_pixels = gfx::Size size_in_pixels =
ui::ConvertSizeToPixel(window_->layer(), window_->bounds().size()); ui::ConvertSizeToPixel(window_->layer(), window_->bounds().size());
ServerWindow* server_window = ServerWindow::GetMayBeNull(window_); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window_);
// It's expected by cc code that any time the size changes a new // It's expected by cc code that any time the size changes a new
// LocalSurfaceId is used. // LocalSurfaceId is used.
if (last_surface_size_in_pixels_ != size_in_pixels || if (last_surface_size_in_pixels_ != size_in_pixels ||
!server_window->local_surface_id().has_value() || !proxy_window->local_surface_id().has_value() ||
last_device_scale_factor_ != window_->layer()->device_scale_factor()) { last_device_scale_factor_ != window_->layer()->device_scale_factor()) {
parent_local_surface_id_allocator_.GenerateId(); parent_local_surface_id_allocator_.GenerateId();
server_window->set_local_surface_id( proxy_window->set_local_surface_id(
parent_local_surface_id_allocator_.GetCurrentLocalSurfaceIdAllocation() parent_local_surface_id_allocator_.GetCurrentLocalSurfaceIdAllocation()
.local_surface_id()); .local_surface_id());
last_surface_size_in_pixels_ = size_in_pixels; last_surface_size_in_pixels_ = size_in_pixels;
@@ -116,28 +115,28 @@ void ClientRoot::OnLocalSurfaceIdChanged() {
: window_->bounds()); : window_->bounds());
} }
void ClientRoot::AttachChildFrameSinkId(ServerWindow* server_window) { void ClientRoot::AttachChildFrameSinkId(ProxyWindow* proxy_window) {
DCHECK(server_window->attached_frame_sink_id().is_valid()); DCHECK(proxy_window->attached_frame_sink_id().is_valid());
DCHECK(ServerWindow::GetMayBeNull(window_)->frame_sink_id().is_valid()); DCHECK(ProxyWindow::GetMayBeNull(window_)->frame_sink_id().is_valid());
viz::HostFrameSinkManager* host_frame_sink_manager = viz::HostFrameSinkManager* host_frame_sink_manager =
window_->env()->context_factory_private()->GetHostFrameSinkManager(); window_->env()->context_factory_private()->GetHostFrameSinkManager();
const viz::FrameSinkId& frame_sink_id = const viz::FrameSinkId& frame_sink_id =
server_window->attached_frame_sink_id(); proxy_window->attached_frame_sink_id();
if (host_frame_sink_manager->IsFrameSinkIdRegistered(frame_sink_id)) { if (host_frame_sink_manager->IsFrameSinkIdRegistered(frame_sink_id)) {
host_frame_sink_manager->RegisterFrameSinkHierarchy( host_frame_sink_manager->RegisterFrameSinkHierarchy(
ServerWindow::GetMayBeNull(window_)->frame_sink_id(), frame_sink_id); ProxyWindow::GetMayBeNull(window_)->frame_sink_id(), frame_sink_id);
} }
} }
void ClientRoot::UnattachChildFrameSinkId(ServerWindow* server_window) { void ClientRoot::UnattachChildFrameSinkId(ProxyWindow* proxy_window) {
DCHECK(server_window->attached_frame_sink_id().is_valid()); DCHECK(proxy_window->attached_frame_sink_id().is_valid());
DCHECK(ServerWindow::GetMayBeNull(window_)->frame_sink_id().is_valid()); DCHECK(ProxyWindow::GetMayBeNull(window_)->frame_sink_id().is_valid());
viz::HostFrameSinkManager* host_frame_sink_manager = viz::HostFrameSinkManager* host_frame_sink_manager =
window_->env()->context_factory_private()->GetHostFrameSinkManager(); window_->env()->context_factory_private()->GetHostFrameSinkManager();
const viz::FrameSinkId& root_frame_sink_id = const viz::FrameSinkId& root_frame_sink_id =
ServerWindow::GetMayBeNull(window_)->frame_sink_id(); ProxyWindow::GetMayBeNull(window_)->frame_sink_id();
const viz::FrameSinkId& window_frame_sink_id = const viz::FrameSinkId& window_frame_sink_id =
server_window->attached_frame_sink_id(); proxy_window->attached_frame_sink_id();
if (host_frame_sink_manager->IsFrameSinkHierarchyRegistered( if (host_frame_sink_manager->IsFrameSinkHierarchyRegistered(
root_frame_sink_id, window_frame_sink_id)) { root_frame_sink_id, window_frame_sink_id)) {
host_frame_sink_manager->UnregisterFrameSinkHierarchy(root_frame_sink_id, host_frame_sink_manager->UnregisterFrameSinkHierarchy(root_frame_sink_id,
@@ -145,35 +144,34 @@ void ClientRoot::UnattachChildFrameSinkId(ServerWindow* server_window) {
} }
} }
void ClientRoot::AttachChildFrameSinkIdRecursive(ServerWindow* server_window) { void ClientRoot::AttachChildFrameSinkIdRecursive(ProxyWindow* proxy_window) {
if (server_window->attached_frame_sink_id().is_valid()) if (proxy_window->attached_frame_sink_id().is_valid())
AttachChildFrameSinkId(server_window); AttachChildFrameSinkId(proxy_window);
for (aura::Window* child : server_window->window()->children()) { for (aura::Window* child : proxy_window->window()->children()) {
ServerWindow* child_server_window = ServerWindow::GetMayBeNull(child); ProxyWindow* child_proxy_window = ProxyWindow::GetMayBeNull(child);
if (child_server_window->owning_window_tree() == window_tree_) if (child_proxy_window->owning_window_tree() == window_tree_)
AttachChildFrameSinkIdRecursive(child_server_window); AttachChildFrameSinkIdRecursive(child_proxy_window);
} }
} }
void ClientRoot::UnattachChildFrameSinkIdRecursive( void ClientRoot::UnattachChildFrameSinkIdRecursive(ProxyWindow* proxy_window) {
ServerWindow* server_window) { if (proxy_window->attached_frame_sink_id().is_valid())
if (server_window->attached_frame_sink_id().is_valid()) UnattachChildFrameSinkId(proxy_window);
UnattachChildFrameSinkId(server_window);
for (aura::Window* child : server_window->window()->children()) { for (aura::Window* child : proxy_window->window()->children()) {
ServerWindow* child_server_window = ServerWindow::GetMayBeNull(child); ProxyWindow* child_proxy_window = ProxyWindow::GetMayBeNull(child);
if (child_server_window->owning_window_tree() == window_tree_) if (child_proxy_window->owning_window_tree() == window_tree_)
UnattachChildFrameSinkIdRecursive(child_server_window); UnattachChildFrameSinkIdRecursive(child_proxy_window);
} }
} }
void ClientRoot::UpdatePrimarySurfaceId() { void ClientRoot::UpdatePrimarySurfaceId() {
UpdateLocalSurfaceIdIfNecessary(); UpdateLocalSurfaceIdIfNecessary();
ServerWindow* server_window = ServerWindow::GetMayBeNull(window_); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window_);
if (server_window->local_surface_id().has_value()) { if (proxy_window->local_surface_id().has_value()) {
client_surface_embedder_->SetSurfaceId(viz::SurfaceId( client_surface_embedder_->SetSurfaceId(viz::SurfaceId(
window_->GetFrameSinkId(), *server_window->local_surface_id())); window_->GetFrameSinkId(), *proxy_window->local_surface_id()));
if (fallback_surface_info_) { if (fallback_surface_info_) {
client_surface_embedder_->SetFallbackSurfaceInfo(*fallback_surface_info_); client_surface_embedder_->SetFallbackSurfaceInfo(*fallback_surface_info_);
fallback_surface_info_.reset(); fallback_surface_info_.reset();
@@ -203,7 +201,7 @@ void ClientRoot::NotifyClientOfNewBounds(const gfx::Rect& old_bounds) {
last_bounds_ = window_->GetBoundsInScreen(); last_bounds_ = window_->GetBoundsInScreen();
window_tree_->window_tree_client_->OnWindowBoundsChanged( window_tree_->window_tree_client_->OnWindowBoundsChanged(
window_tree_->TransportIdForWindow(window_), old_bounds, last_bounds_, window_tree_->TransportIdForWindow(window_), old_bounds, last_bounds_,
ServerWindow::GetMayBeNull(window_)->local_surface_id()); ProxyWindow::GetMayBeNull(window_)->local_surface_id());
} }
void ClientRoot::OnPositionInRootChanged() { void ClientRoot::OnPositionInRootChanged() {
@@ -303,8 +301,8 @@ void ClientRoot::OnHostResized(aura::WindowTreeHost* host) {
void ClientRoot::OnFirstSurfaceActivation( void ClientRoot::OnFirstSurfaceActivation(
const viz::SurfaceInfo& surface_info) { const viz::SurfaceInfo& surface_info) {
ServerWindow* server_window = ServerWindow::GetMayBeNull(window_); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window_);
if (server_window->local_surface_id().has_value()) { if (proxy_window->local_surface_id().has_value()) {
DCHECK(!fallback_surface_info_); DCHECK(!fallback_surface_info_);
if (!client_surface_embedder_->HasPrimarySurfaceId()) if (!client_surface_embedder_->HasPrimarySurfaceId())
UpdatePrimarySurfaceId(); UpdatePrimarySurfaceId();
@@ -315,7 +313,7 @@ void ClientRoot::OnFirstSurfaceActivation(
if (!window_tree_->client_name().empty()) { if (!window_tree_->client_name().empty()) {
// OnFirstSurfaceActivation() should only be called after // OnFirstSurfaceActivation() should only be called after
// AttachCompositorFrameSink(). // AttachCompositorFrameSink().
DCHECK(server_window->attached_compositor_frame_sink()); DCHECK(proxy_window->attached_compositor_frame_sink());
window_tree_->window_service()->OnFirstSurfaceActivation( window_tree_->window_service()->OnFirstSurfaceActivation(
window_tree_->client_name()); window_tree_->client_name());
} }

@@ -37,7 +37,7 @@ class SurfaceInfo;
namespace ws { namespace ws {
class ServerWindow; class ProxyWindow;
class WindowTree; class WindowTree;
// WindowTree creates a ClientRoot for each window the client is embedded in. A // WindowTree creates a ClientRoot for each window the client is embedded in. A
@@ -68,15 +68,15 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) ClientRoot
// Called when the LocalSurfaceId of the embedder changes. // Called when the LocalSurfaceId of the embedder changes.
void OnLocalSurfaceIdChanged(); void OnLocalSurfaceIdChanged();
// Attaches/unattaches server_window->attached_frame_sink_id() to the // Attaches/unattaches proxy_window->attached_frame_sink_id() to the
// HostFrameSinkManager. // HostFrameSinkManager.
void AttachChildFrameSinkId(ServerWindow* server_window); void AttachChildFrameSinkId(ProxyWindow* proxy_window);
void UnattachChildFrameSinkId(ServerWindow* server_window); void UnattachChildFrameSinkId(ProxyWindow* proxy_window);
// Recurses through all descendants with the same WindowTree calling // Recurses through all descendants with the same WindowTree calling
// AttachChildFrameSinkId()/UnattachChildFrameSinkId(). // AttachChildFrameSinkId()/UnattachChildFrameSinkId().
void AttachChildFrameSinkIdRecursive(ServerWindow* server_window); void AttachChildFrameSinkIdRecursive(ProxyWindow* proxy_window);
void UnattachChildFrameSinkIdRecursive(ServerWindow* server_window); void UnattachChildFrameSinkIdRecursive(ProxyWindow* proxy_window);
private: private:
friend class ClientRootTestHelper; friend class ClientRootTestHelper;

@@ -16,7 +16,7 @@ namespace ws {
class ClientRoot; class ClientRoot;
// Used for accessing private members of ServerWindow in tests. // Used for accessing private members of ClientRoot in tests.
class ClientRootTestHelper { class ClientRootTestHelper {
public: public:
explicit ClientRootTestHelper(ClientRoot* client_root); explicit ClientRootTestHelper(ClientRoot* client_root);

@@ -79,7 +79,7 @@ bool EventQueue::ShouldQueueEvent(HostEventQueue* host_queue,
DCHECK(targeter); DCHECK(targeter);
aura::Window* target = aura::Window* target =
targeter->FindTargetForKeyEvent(host_queue->window_tree_host()->window()); targeter->FindTargetForKeyEvent(host_queue->window_tree_host()->window());
return target && WindowService::HasRemoteClient(target); return target && WindowService::IsProxyWindow(target);
} }
void EventQueue::NotifyWhenReadyToDispatch(base::OnceClosure closure) { void EventQueue::NotifyWhenReadyToDispatch(base::OnceClosure closure) {

@@ -6,7 +6,7 @@
#include "services/ws/client_change.h" #include "services/ws/client_change.h"
#include "services/ws/client_change_tracker.h" #include "services/ws/client_change_tracker.h"
#include "services/ws/server_window.h" #include "services/ws/proxy_window.h"
#include "services/ws/window_properties.h" #include "services/ws/window_properties.h"
#include "services/ws/window_service.h" #include "services/ws/window_service.h"
#include "services/ws/window_service_delegate.h" #include "services/ws/window_service_delegate.h"
@@ -43,17 +43,17 @@ bool FocusHandler::SetFocus(aura::Window* window) {
aura::client::FocusClient* focus_client = aura::client::FocusClient* focus_client =
window_tree_->window_service_->focus_client(); window_tree_->window_service_->focus_client();
ServerWindow* server_window = ServerWindow::GetMayBeNull(window); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window);
if (window == focus_client->GetFocusedWindow()) { if (window == focus_client->GetFocusedWindow()) {
if (server_window->focus_owner() != window_tree_) { if (proxy_window->focus_owner() != window_tree_) {
// The focused window didn't change, but the client that owns focus did // The focused window didn't change, but the client that owns focus did
// (see |ServerWindow::focus_owner_| for details on this). Notify the // (see |ProxyWindow::focus_owner_| for details on this). Notify the
// current owner that it lost focus. // current owner that it lost focus.
if (server_window->focus_owner()) { if (proxy_window->focus_owner()) {
server_window->focus_owner()->window_tree_client_->OnWindowFocused( proxy_window->focus_owner()->window_tree_client_->OnWindowFocused(
kInvalidTransportId); kInvalidTransportId);
} }
server_window->set_focus_owner(window_tree_); proxy_window->set_focus_owner(window_tree_);
} }
return true; return true;
} }
@@ -75,8 +75,8 @@ bool FocusHandler::SetFocus(aura::Window* window) {
<< " failed for " << window->GetName() << ")"; << " failed for " << window->GetName() << ")";
return false; return false;
} }
if (server_window) if (proxy_window)
server_window->set_focus_owner(window_tree_); proxy_window->set_focus_owner(window_tree_);
return true; return true;
} }
} }
@@ -88,8 +88,8 @@ bool FocusHandler::SetFocus(aura::Window* window) {
return false; return false;
} }
if (server_window) if (proxy_window)
server_window->set_focus_owner(window_tree_); proxy_window->set_focus_owner(window_tree_);
return true; return true;
} }
@@ -113,12 +113,12 @@ bool FocusHandler::IsFocusableWindow(aura::Window* window) const {
window_tree_->IsClientRootWindow(window)); window_tree_->IsClientRootWindow(window));
} }
bool FocusHandler::IsEmbeddedClient(ServerWindow* server_window) const { bool FocusHandler::IsEmbeddedClient(ProxyWindow* proxy_window) const {
return server_window->embedded_window_tree() == window_tree_; return proxy_window->embedded_window_tree() == window_tree_;
} }
bool FocusHandler::IsOwningClient(ServerWindow* server_window) const { bool FocusHandler::IsOwningClient(ProxyWindow* proxy_window) const {
return server_window->owning_window_tree() == window_tree_; return proxy_window->owning_window_tree() == window_tree_;
} }
void FocusHandler::OnWindowFocused(aura::Window* gained_focus, void FocusHandler::OnWindowFocused(aura::Window* gained_focus,
@@ -137,11 +137,11 @@ void FocusHandler::OnWindowFocused(aura::Window* gained_focus,
// Prefer the embedded client over the owning client. // Prefer the embedded client over the owning client.
bool notified_gained = false; bool notified_gained = false;
if (gained_focus) { if (gained_focus) {
ServerWindow* server_window = ServerWindow::GetMayBeNull(gained_focus); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(gained_focus);
if (server_window && (IsEmbeddedClient(server_window) || if (proxy_window && (IsEmbeddedClient(proxy_window) ||
(!server_window->embedded_window_tree() && (!proxy_window->embedded_window_tree() &&
IsOwningClient(server_window)))) { IsOwningClient(proxy_window)))) {
server_window->set_focus_owner(window_tree_); proxy_window->set_focus_owner(window_tree_);
window_tree_->window_tree_client_->OnWindowFocused( window_tree_->window_tree_client_->OnWindowFocused(
window_tree_->TransportIdForWindow(gained_focus)); window_tree_->TransportIdForWindow(gained_focus));
notified_gained = true; notified_gained = true;
@@ -149,9 +149,9 @@ void FocusHandler::OnWindowFocused(aura::Window* gained_focus,
} }
if (lost_focus && !notified_gained) { if (lost_focus && !notified_gained) {
ServerWindow* server_window = ServerWindow::GetMayBeNull(lost_focus); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(lost_focus);
if (server_window && server_window->focus_owner() == window_tree_) { if (proxy_window && proxy_window->focus_owner() == window_tree_) {
server_window->set_focus_owner(nullptr); proxy_window->set_focus_owner(nullptr);
window_tree_->window_tree_client_->OnWindowFocused(kInvalidTransportId); window_tree_->window_tree_client_->OnWindowFocused(kInvalidTransportId);
} }
} }

@@ -14,7 +14,7 @@ class Window;
namespace ws { namespace ws {
class ServerWindow; class ProxyWindow;
class WindowTree; class WindowTree;
// FocusHandler handles focus requests from the client, as well as notifying // FocusHandler handles focus requests from the client, as well as notifying
@@ -34,8 +34,8 @@ class FocusHandler : public aura::client::FocusChangeObserver {
// Returns true if |window| can be focused. // Returns true if |window| can be focused.
bool IsFocusableWindow(aura::Window* window) const; bool IsFocusableWindow(aura::Window* window) const;
bool IsEmbeddedClient(ServerWindow* server_window) const; bool IsEmbeddedClient(ProxyWindow* proxy_window) const;
bool IsOwningClient(ServerWindow* server_window) const; bool IsOwningClient(ProxyWindow* proxy_window) const;
// aura::client::FocusChangeObserver: // aura::client::FocusChangeObserver:
void OnWindowFocused(aura::Window* gained_focus, void OnWindowFocused(aura::Window* gained_focus,

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "services/ws/server_window.h" #include "services/ws/proxy_window.h"
#include <utility> #include <utility>
@@ -24,19 +24,19 @@
#include "ui/wm/core/capture_controller.h" #include "ui/wm/core/capture_controller.h"
#include "ui/wm/core/window_modality_controller.h" #include "ui/wm/core/window_modality_controller.h"
DEFINE_UI_CLASS_PROPERTY_TYPE(ws::ServerWindow*); DEFINE_UI_CLASS_PROPERTY_TYPE(ws::ProxyWindow*);
namespace ws { namespace ws {
namespace { namespace {
DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(ServerWindow, kServerWindowKey, nullptr); DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(ProxyWindow, kProxyWindowKey, nullptr);
// Returns true if |location| is in the non-client area (or outside the bounds // Returns true if |location| is in the non-client area (or outside the bounds
// of the window). A return value of false means the location is in the client // of the window). A return value of false means the location is in the client
// area. // area.
bool IsLocationInNonClientArea(const aura::Window* window, bool IsLocationInNonClientArea(const aura::Window* window,
const gfx::Point& location) { const gfx::Point& location) {
const ServerWindow* server_window = ServerWindow::GetMayBeNull(window); const ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window);
if (!server_window || !server_window->IsTopLevel()) if (!proxy_window || !proxy_window->IsTopLevel())
return false; return false;
// Locations inside bounds but within the resize insets count as non-client // Locations inside bounds but within the resize insets count as non-client
@@ -57,11 +57,11 @@ bool IsLocationInNonClientArea(const aura::Window* window,
} }
gfx::Rect client_area(window->bounds().size()); gfx::Rect client_area(window->bounds().size());
client_area.Inset(server_window->client_area()); client_area.Inset(proxy_window->client_area());
if (client_area.Contains(location)) if (client_area.Contains(location))
return false; return false;
for (const auto& rect : server_window->additional_client_areas()) { for (const auto& rect : proxy_window->additional_client_areas()) {
if (rect.Contains(location)) if (rect.Contains(location))
return false; return false;
} }
@@ -95,16 +95,16 @@ ui::PointerId GetPointerId(const ui::Event& event) {
return event.AsTouchEvent()->pointer_details().id; return event.AsTouchEvent()->pointer_details().id;
} }
// WindowTargeter used for ServerWindows. This is used for two purposes: // WindowTargeter used for ProxyWindows. This is used for two purposes:
// . If the location is in the non-client area, then child Windows are not // . If the location is in the non-client area, then child Windows are not
// considered. This is done to ensure the delegate of the window (which is // considered. This is done to ensure the delegate of the window (which is
// local) sees the event. // local) sees the event.
// . To ensure |WindowTree::intercepts_events_| is honored. // . To ensure |WindowTree::intercepts_events_| is honored.
class ServerWindowTargeter : public aura::WindowTargeter { class ProxyWindowTargeter : public aura::WindowTargeter {
public: public:
explicit ServerWindowTargeter(ServerWindow* server_window) explicit ProxyWindowTargeter(ProxyWindow* proxy_window)
: server_window_(server_window) {} : proxy_window_(proxy_window) {}
~ServerWindowTargeter() override = default; ~ProxyWindowTargeter() override = default;
// aura::WindowTargeter: // aura::WindowTargeter:
bool SubtreeShouldBeExploredForEvent(aura::Window* window, bool SubtreeShouldBeExploredForEvent(aura::Window* window,
@@ -113,7 +113,7 @@ class ServerWindowTargeter : public aura::WindowTargeter {
// parent's WindowTargeter. This is necessary for targeters such as // parent's WindowTargeter. This is necessary for targeters such as
// EasyResizeWindowTargeter to work correctly. // EasyResizeWindowTargeter to work correctly.
if (mouse_extend().IsEmpty() && touch_extend().IsEmpty() && if (mouse_extend().IsEmpty() && touch_extend().IsEmpty() &&
server_window_->IsTopLevel() && window->parent()) { proxy_window_->IsTopLevel() && window->parent()) {
aura::WindowTargeter* parent_targeter = aura::WindowTargeter* parent_targeter =
static_cast<WindowTargeter*>(window->parent()->targeter()); static_cast<WindowTargeter*>(window->parent()->targeter());
if (parent_targeter) if (parent_targeter)
@@ -125,8 +125,8 @@ class ServerWindowTargeter : public aura::WindowTargeter {
ui::EventTarget* FindTargetForEvent(ui::EventTarget* event_target, ui::EventTarget* FindTargetForEvent(ui::EventTarget* event_target,
ui::Event* event) override { ui::Event* event) override {
aura::Window* window = static_cast<aura::Window*>(event_target); aura::Window* window = static_cast<aura::Window*>(event_target);
DCHECK_EQ(window, server_window_->window()); DCHECK_EQ(window, proxy_window_->window());
if (server_window_->DoesOwnerInterceptEvents()) { if (proxy_window_->DoesOwnerInterceptEvents()) {
// If the owner intercepts events, then don't recurse (otherwise events // If the owner intercepts events, then don't recurse (otherwise events
// would go to a descendant). // would go to a descendant).
return event_target->CanAcceptEvent(*event) ? window : nullptr; return event_target->CanAcceptEvent(*event) ? window : nullptr;
@@ -143,28 +143,28 @@ class ServerWindowTargeter : public aura::WindowTargeter {
} }
private: private:
ServerWindow* const server_window_; ProxyWindow* const proxy_window_;
DISALLOW_COPY_AND_ASSIGN(ServerWindowTargeter); DISALLOW_COPY_AND_ASSIGN(ProxyWindowTargeter);
}; };
// ServerWindowEventHandler is used to forward events to the client. // ProxyWindowEventHandler is used to forward events to the client.
// ServerWindowEventHandler adds itself to the pre-phase to ensure it's // ProxyWindowEventHandler adds itself to the pre-phase to ensure it's
// considered before the Window's delegate (or other EventHandlers). // considered before the Window's delegate (or other EventHandlers).
class ServerWindowEventHandler : public ui::EventHandler { class ProxyWindowEventHandler : public ui::EventHandler {
public: public:
explicit ServerWindowEventHandler(ServerWindow* server_window) explicit ProxyWindowEventHandler(ProxyWindow* proxy_window)
: server_window_(server_window) { : proxy_window_(proxy_window) {
// Use |kDefault| so as not to conflict with other important pre-target // Use |kDefault| so as not to conflict with other important pre-target
// handlers (such as laser pointer). // handlers (such as laser pointer).
window()->AddPreTargetHandler(this, ui::EventTarget::Priority::kDefault); window()->AddPreTargetHandler(this, ui::EventTarget::Priority::kDefault);
} }
~ServerWindowEventHandler() override { ~ProxyWindowEventHandler() override {
window()->RemovePreTargetHandler(this); window()->RemovePreTargetHandler(this);
} }
ServerWindow* server_window() { return server_window_; } ProxyWindow* proxy_window() { return proxy_window_; }
aura::Window* window() { return server_window_->window(); } aura::Window* window() { return proxy_window_->window(); }
// ui::EventHandler: // ui::EventHandler:
void OnEvent(ui::Event* event) override { void OnEvent(ui::Event* event) override {
@@ -178,19 +178,19 @@ class ServerWindowEventHandler : public ui::EventHandler {
if (HandleInterceptedEvent(event) || ShouldIgnoreEvent(*event)) if (HandleInterceptedEvent(event) || ShouldIgnoreEvent(*event))
return; return;
auto* owning = server_window_->owning_window_tree(); auto* owning = proxy_window_->owning_window_tree();
auto* embedded = server_window_->embedded_window_tree(); auto* embedded = proxy_window_->embedded_window_tree();
WindowTree* target_client = nullptr; WindowTree* target_client = nullptr;
if (server_window_->DoesOwnerInterceptEvents()) { if (proxy_window_->DoesOwnerInterceptEvents()) {
// A client that intercepts events, always gets the event regardless of // A client that intercepts events, always gets the event regardless of
// focus/capture. // focus/capture.
target_client = owning; target_client = owning;
} else if (event->IsKeyEvent()) { } else if (event->IsKeyEvent()) {
if (!server_window_->focus_owner()) if (!proxy_window_->focus_owner())
return; // The local environment is going to process the event. return; // The local environment is going to process the event.
target_client = server_window_->focus_owner(); target_client = proxy_window_->focus_owner();
} else if (server_window()->capture_owner()) { } else if (proxy_window()->capture_owner()) {
target_client = server_window()->capture_owner(); target_client = proxy_window()->capture_owner();
} else { } else {
// Prefer embedded over owner. // Prefer embedded over owner.
target_client = !embedded ? owning : embedded; target_client = !embedded ? owning : embedded;
@@ -213,7 +213,7 @@ class ServerWindowEventHandler : public ui::EventHandler {
return true; return true;
if (static_cast<aura::Window*>(event.target()) != window()) { if (static_cast<aura::Window*>(event.target()) != window()) {
// As ServerWindow is a EP_PRETARGET EventHandler it gets events *before* // As ProxyWindow is a EP_PRETARGET EventHandler it gets events *before*
// descendants. Ignore all such events, and only process when // descendants. Ignore all such events, and only process when
// window() is the the target. // window() is the the target.
return true; return true;
@@ -245,10 +245,10 @@ class ServerWindowEventHandler : public ui::EventHandler {
return false; return false;
// KeyEvents, and events when there is capture, do not go through through // KeyEvents, and events when there is capture, do not go through through
// ServerWindowTargeter. As a result ServerWindowEventHandler has to check // ProxyWindowTargeter. As a result ProxyWindowEventHandler has to check
// for a client intercepting events. // for a client intercepting events.
if (server_window_->DoesOwnerInterceptEvents()) { if (proxy_window_->DoesOwnerInterceptEvents()) {
server_window_->owning_window_tree()->SendEventToClient(window(), *event); proxy_window_->owning_window_tree()->SendEventToClient(window(), *event);
if (event->cancelable()) if (event->cancelable())
event->StopPropagation(); event->StopPropagation();
return true; return true;
@@ -257,9 +257,9 @@ class ServerWindowEventHandler : public ui::EventHandler {
} }
private: private:
ServerWindow* const server_window_; ProxyWindow* const proxy_window_;
DISALLOW_COPY_AND_ASSIGN(ServerWindowEventHandler); DISALLOW_COPY_AND_ASSIGN(ProxyWindowEventHandler);
}; };
class TopLevelEventHandler; class TopLevelEventHandler;
@@ -300,13 +300,13 @@ class PointerPressHandler : public aura::client::CaptureClientObserver,
// area are not sent to the client, instead are handled locally. For example, // area are not sent to the client, instead are handled locally. For example,
// if a press occurs in the non-client area, then the event is not sent to // if a press occurs in the non-client area, then the event is not sent to
// the client, it's handled locally. // the client, it's handled locally.
class TopLevelEventHandler : public ServerWindowEventHandler { class TopLevelEventHandler : public ProxyWindowEventHandler {
public: public:
explicit TopLevelEventHandler(ServerWindow* server_window) explicit TopLevelEventHandler(ProxyWindow* proxy_window)
: ServerWindowEventHandler(server_window) { : ProxyWindowEventHandler(proxy_window) {
// Top-levels should always have an owning_window_tree(). // Top-levels should always have an owning_window_tree().
// OnEvent() assumes this. // OnEvent() assumes this.
DCHECK(server_window->owning_window_tree()); DCHECK(proxy_window->owning_window_tree());
} }
~TopLevelEventHandler() override = default; ~TopLevelEventHandler() override = default;
@@ -330,7 +330,7 @@ class TopLevelEventHandler : public ServerWindowEventHandler {
pointer_press_handlers_.clear(); pointer_press_handlers_.clear();
} }
// ServerWindowEventHandler: // ProxyWindowEventHandler:
void OnEvent(ui::Event* event) override { void OnEvent(ui::Event* event) override {
if (event->phase() != ui::EP_PRETARGET) { if (event->phase() != ui::EP_PRETARGET) {
// All work is done in the pre-phase. If this branch is hit, it means // All work is done in the pre-phase. If this branch is hit, it means
@@ -343,7 +343,7 @@ class TopLevelEventHandler : public ServerWindowEventHandler {
return; return;
if (!event->IsLocatedEvent()) { if (!event->IsLocatedEvent()) {
ServerWindowEventHandler::OnEvent(event); ProxyWindowEventHandler::OnEvent(event);
return; return;
} }
@@ -353,8 +353,8 @@ class TopLevelEventHandler : public ServerWindowEventHandler {
// If there is capture, send the event to the client that owns it. A null // If there is capture, send the event to the client that owns it. A null
// capture owner means the local environment should handle the event. // capture owner means the local environment should handle the event.
if (wm::CaptureController::Get()->GetCaptureWindow()) { if (wm::CaptureController::Get()->GetCaptureWindow()) {
if (server_window()->capture_owner()) { if (proxy_window()->capture_owner()) {
server_window()->capture_owner()->SendEventToClient(window(), *event); proxy_window()->capture_owner()->SendEventToClient(window(), *event);
if (event->cancelable()) if (event->cancelable())
event->StopPropagation(); event->StopPropagation();
return; return;
@@ -368,7 +368,7 @@ class TopLevelEventHandler : public ServerWindowEventHandler {
// local, otherwise remote client. // local, otherwise remote client.
// . mouse-moves (not drags) go to both targets. // . mouse-moves (not drags) go to both targets.
bool stop_propagation = false; bool stop_propagation = false;
if (server_window()->HasNonClientArea() && IsPointerEvent(*event)) { if (proxy_window()->HasNonClientArea() && IsPointerEvent(*event)) {
const ui::PointerId pointer_id = GetPointerId(*event); const ui::PointerId pointer_id = GetPointerId(*event);
if (!pointer_press_handlers_.count(pointer_id)) { if (!pointer_press_handlers_.count(pointer_id)) {
if (IsPointerPressedEvent(*event)) { if (IsPointerPressedEvent(*event)) {
@@ -393,7 +393,7 @@ class TopLevelEventHandler : public ServerWindowEventHandler {
stop_propagation = true; stop_propagation = true;
} }
} }
server_window()->owning_window_tree()->SendEventToClient(window(), *event); proxy_window()->owning_window_tree()->SendEventToClient(window(), *event);
if (stop_propagation && event->cancelable()) if (stop_propagation && event->cancelable())
event->StopPropagation(); event->StopPropagation();
} }
@@ -439,47 +439,47 @@ void PointerPressHandler::OnWindowVisibilityChanged(aura::Window* window,
} // namespace } // namespace
ServerWindow::~ServerWindow() { ProxyWindow::~ProxyWindow() {
// WindowTree/ClientRoot should have reset |attached_frame_sink_id_| before // WindowTree/ClientRoot should have reset |attached_frame_sink_id_| before
// the Window is destroyed. // the Window is destroyed.
DCHECK(!attached_frame_sink_id_.is_valid()); DCHECK(!attached_frame_sink_id_.is_valid());
} }
// static // static
ServerWindow* ServerWindow::Create(aura::Window* window, ProxyWindow* ProxyWindow::Create(aura::Window* window,
WindowTree* tree, WindowTree* tree,
const viz::FrameSinkId& frame_sink_id, const viz::FrameSinkId& frame_sink_id,
bool is_top_level) { bool is_top_level) {
DCHECK(!GetMayBeNull(window)); DCHECK(!GetMayBeNull(window));
// Owned by |window|. // Owned by |window|.
ServerWindow* server_window = ProxyWindow* proxy_window =
new ServerWindow(window, tree, frame_sink_id, is_top_level); new ProxyWindow(window, tree, frame_sink_id, is_top_level);
return server_window; return proxy_window;
} }
// static // static
const ServerWindow* ServerWindow::GetMayBeNull(const aura::Window* window) { const ProxyWindow* ProxyWindow::GetMayBeNull(const aura::Window* window) {
return window ? window->GetProperty(kServerWindowKey) : nullptr; return window ? window->GetProperty(kProxyWindowKey) : nullptr;
} }
void ServerWindow::Destroy() { void ProxyWindow::Destroy() {
// This should only be called for windows created locally for an embedding // This should only be called for windows created locally for an embedding
// (not created by a remote client). Such windows do not have an owner. // (not created by a remote client). Such windows do not have an owner.
DCHECK(!owning_window_tree_); DCHECK(!owning_window_tree_);
// static_cast is needed to determine which function SetProperty() applies // static_cast is needed to determine which function SetProperty() applies
// to. // to.
window_->SetProperty(kServerWindowKey, static_cast<ServerWindow*>(nullptr)); window_->SetProperty(kProxyWindowKey, static_cast<ProxyWindow*>(nullptr));
} }
WindowTree* ServerWindow::embedded_window_tree() { WindowTree* ProxyWindow::embedded_window_tree() {
return embedding_ ? embedding_->embedded_tree() : nullptr; return embedding_ ? embedding_->embedded_tree() : nullptr;
} }
const WindowTree* ServerWindow::embedded_window_tree() const { const WindowTree* ProxyWindow::embedded_window_tree() const {
return embedding_ ? embedding_->embedded_tree() : nullptr; return embedding_ ? embedding_->embedded_tree() : nullptr;
} }
void ServerWindow::SetClientArea( void ProxyWindow::SetClientArea(
const gfx::Insets& insets, const gfx::Insets& insets,
const std::vector<gfx::Rect>& additional_client_areas) { const std::vector<gfx::Rect>& additional_client_areas) {
if (client_area_ == insets && if (client_area_ == insets &&
@@ -496,12 +496,12 @@ void ServerWindow::SetClientArea(
client_root->SetClientAreaInsets(insets); client_root->SetClientAreaInsets(insets);
} }
void ServerWindow::SetHitTestInsets(const gfx::Insets& mouse, void ProxyWindow::SetHitTestInsets(const gfx::Insets& mouse,
const gfx::Insets& touch) { const gfx::Insets& touch) {
window_targeter_->SetInsets(mouse, touch); window_targeter_->SetInsets(mouse, touch);
} }
void ServerWindow::SetCaptureOwner(WindowTree* owner) { void ProxyWindow::SetCaptureOwner(WindowTree* owner) {
capture_owner_ = owner; capture_owner_ = owner;
if (!IsTopLevel()) if (!IsTopLevel())
return; return;
@@ -510,28 +510,28 @@ void ServerWindow::SetCaptureOwner(WindowTree* owner) {
->OnCaptureOwnerChanged(); ->OnCaptureOwnerChanged();
} }
void ServerWindow::StoreCursor(const ui::Cursor& cursor) { void ProxyWindow::StoreCursor(const ui::Cursor& cursor) {
cursor_ = cursor; cursor_ = cursor;
} }
bool ServerWindow::DoesOwnerInterceptEvents() const { bool ProxyWindow::DoesOwnerInterceptEvents() const {
return embedding_ && embedding_->embedding_tree_intercepts_events(); return embedding_ && embedding_->embedding_tree_intercepts_events();
} }
void ServerWindow::SetEmbedding(std::unique_ptr<Embedding> embedding) { void ProxyWindow::SetEmbedding(std::unique_ptr<Embedding> embedding) {
embedding_ = std::move(embedding); embedding_ = std::move(embedding);
} }
bool ServerWindow::HasNonClientArea() const { bool ProxyWindow::HasNonClientArea() const {
return owning_window_tree_ && owning_window_tree_->IsTopLevel(window_) && return owning_window_tree_ && owning_window_tree_->IsTopLevel(window_) &&
(!client_area_.IsEmpty() || !additional_client_areas_.empty()); (!client_area_.IsEmpty() || !additional_client_areas_.empty());
} }
bool ServerWindow::IsTopLevel() const { bool ProxyWindow::IsTopLevel() const {
return owning_window_tree_ && owning_window_tree_->IsTopLevel(window_); return owning_window_tree_ && owning_window_tree_->IsTopLevel(window_);
} }
void ServerWindow::AttachCompositorFrameSink( void ProxyWindow::AttachCompositorFrameSink(
viz::mojom::CompositorFrameSinkRequest compositor_frame_sink, viz::mojom::CompositorFrameSinkRequest compositor_frame_sink,
viz::mojom::CompositorFrameSinkClientPtr client) { viz::mojom::CompositorFrameSinkClientPtr client) {
attached_compositor_frame_sink_ = true; attached_compositor_frame_sink_ = true;
@@ -541,32 +541,32 @@ void ServerWindow::AttachCompositorFrameSink(
frame_sink_id_, std::move(compositor_frame_sink), std::move(client)); frame_sink_id_, std::move(compositor_frame_sink), std::move(client));
} }
void ServerWindow::SetDragDropDelegate( void ProxyWindow::SetDragDropDelegate(
std::unique_ptr<DragDropDelegate> drag_drop_delegate) { std::unique_ptr<DragDropDelegate> drag_drop_delegate) {
drag_drop_delegate_ = std::move(drag_drop_delegate); drag_drop_delegate_ = std::move(drag_drop_delegate);
} }
std::string ServerWindow::GetIdForDebugging() { std::string ProxyWindow::GetIdForDebugging() {
return owning_window_tree_ return owning_window_tree_
? owning_window_tree_->ClientWindowIdForWindow(window_).ToString() ? owning_window_tree_->ClientWindowIdForWindow(window_).ToString()
: frame_sink_id_.ToString(); : frame_sink_id_.ToString();
} }
ServerWindow::ServerWindow(aura::Window* window, ProxyWindow::ProxyWindow(aura::Window* window,
WindowTree* tree, WindowTree* tree,
const viz::FrameSinkId& frame_sink_id, const viz::FrameSinkId& frame_sink_id,
bool is_top_level) bool is_top_level)
: window_(window), : window_(window),
owning_window_tree_(tree), owning_window_tree_(tree),
frame_sink_id_(frame_sink_id) { frame_sink_id_(frame_sink_id) {
window_->SetProperty(kServerWindowKey, this); window_->SetProperty(kProxyWindowKey, this);
if (is_top_level) if (is_top_level)
event_handler_ = std::make_unique<TopLevelEventHandler>(this); event_handler_ = std::make_unique<TopLevelEventHandler>(this);
else else
event_handler_ = std::make_unique<ServerWindowEventHandler>(this); event_handler_ = std::make_unique<ProxyWindowEventHandler>(this);
auto server_window_targeter = std::make_unique<ServerWindowTargeter>(this); auto proxy_window_targeter = std::make_unique<ProxyWindowTargeter>(this);
window_targeter_ = server_window_targeter.get(); window_targeter_ = proxy_window_targeter.get();
window_->SetEventTargeter(std::move(server_window_targeter)); window_->SetEventTargeter(std::move(proxy_window_targeter));
// In order for a window to receive events it must have a target_handler() // In order for a window to receive events it must have a target_handler()
// (see Window::CanAcceptEvent()). Normally the delegate is the TargetHandler, // (see Window::CanAcceptEvent()). Normally the delegate is the TargetHandler,
// but if the delegate is null, then so is the target_handler(). Set // but if the delegate is null, then so is the target_handler(). Set
@@ -576,7 +576,7 @@ ServerWindow::ServerWindow(aura::Window* window,
window_->SetTargetHandler(event_handler_.get()); window_->SetTargetHandler(event_handler_.get());
} }
bool ServerWindow::IsHandlingPointerPressForTesting(ui::PointerId pointer_id) { bool ProxyWindow::IsHandlingPointerPressForTesting(ui::PointerId pointer_id) {
DCHECK(IsTopLevel()); DCHECK(IsTopLevel());
return static_cast<TopLevelEventHandler*>(event_handler_.get()) return static_cast<TopLevelEventHandler*>(event_handler_.get())
->IsHandlingPointerPress(pointer_id); ->IsHandlingPointerPress(pointer_id);

@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef SERVICES_WS_SERVER_WINDOW_H_ #ifndef SERVICES_WS_PROXY_WINDOW_H_
#define SERVICES_WS_SERVER_WINDOW_H_ #define SERVICES_WS_PROXY_WINDOW_H_
#include <string> #include <string>
#include <vector> #include <vector>
@@ -36,29 +36,29 @@ class Embedding;
class WindowTree; class WindowTree;
// Tracks any state associated with an aura::Window for the WindowService. // Tracks any state associated with an aura::Window for the WindowService.
// ServerWindow is created for every window created at the request of a client, // ProxyWindow is created for every window created at the request of a client,
// including the root window of ClientRoots. // including the root window of ClientRoots.
class COMPONENT_EXPORT(WINDOW_SERVICE) ServerWindow { class COMPONENT_EXPORT(WINDOW_SERVICE) ProxyWindow {
public: public:
~ServerWindow(); ~ProxyWindow();
// Creates a new ServerWindow. The lifetime of the ServerWindow is tied to // Creates a new ProxyWindow. The lifetime of the ProxyWindow is tied to
// that of the Window (the Window ends up owning the ServerWindow). // that of the Window (the Window ends up owning the ProxyWindow).
// |is_top_level| is true if the window represents a top-level window. // |is_top_level| is true if the window represents a top-level window.
static ServerWindow* Create(aura::Window* window, static ProxyWindow* Create(aura::Window* window,
WindowTree* tree, WindowTree* tree,
const viz::FrameSinkId& frame_sink_id, const viz::FrameSinkId& frame_sink_id,
bool is_top_level); bool is_top_level);
// Returns the ServerWindow associated with a window, null if not created yet. // Returns the ProxyWindow associated with a window, null if not created yet.
static ServerWindow* GetMayBeNull(aura::Window* window) { static ProxyWindow* GetMayBeNull(aura::Window* window) {
return const_cast<ServerWindow*>( return const_cast<ProxyWindow*>(
GetMayBeNull(const_cast<const aura::Window*>(window))); GetMayBeNull(const_cast<const aura::Window*>(window)));
} }
static const ServerWindow* GetMayBeNull(const aura::Window* window); static const ProxyWindow* GetMayBeNull(const aura::Window* window);
// Explicitly deletes this ServerWindow. This should very rarely be called. // Explicitly deletes this ProxyWindow. This should very rarely be called.
// The typical use case is ServerWindow is owned by the aura::Window, and // The typical use case is ProxyWindow is owned by the aura::Window, and
// deleted when the associated window is deleted. // deleted when the associated window is deleted.
void Destroy(); void Destroy();
@@ -143,12 +143,12 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) ServerWindow {
std::string GetIdForDebugging(); std::string GetIdForDebugging();
private: private:
friend class ServerWindowTestHelper; friend class ProxyWindowTestHelper;
ServerWindow(aura::Window*, ProxyWindow(aura::Window*,
WindowTree* tree, WindowTree* tree,
const viz::FrameSinkId& frame_sink_id, const viz::FrameSinkId& frame_sink_id,
bool is_top_level); bool is_top_level);
// Forwards to TopLevelEventHandler, see it for details. // Forwards to TopLevelEventHandler, see it for details.
// NOTE: this is only applicable to top-levels. // NOTE: this is only applicable to top-levels.
@@ -209,9 +209,9 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) ServerWindow {
// FrameSinkId set by way of mojom::WindowTree::AttachFrameSinkId(). // FrameSinkId set by way of mojom::WindowTree::AttachFrameSinkId().
viz::FrameSinkId attached_frame_sink_id_; viz::FrameSinkId attached_frame_sink_id_;
DISALLOW_COPY_AND_ASSIGN(ServerWindow); DISALLOW_COPY_AND_ASSIGN(ProxyWindow);
}; };
} // namespace ws } // namespace ws
#endif // SERVICES_WS_SERVER_WINDOW_H_ #endif // SERVICES_WS_PROXY_WINDOW_H_

@@ -0,0 +1,20 @@
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "services/ws/proxy_window_test_helper.h"
#include "services/ws/proxy_window.h"
namespace ws {
ProxyWindowTestHelper::ProxyWindowTestHelper(ProxyWindow* proxy_window)
: proxy_window_(proxy_window) {}
ProxyWindowTestHelper::~ProxyWindowTestHelper() = default;
bool ProxyWindowTestHelper::IsHandlingPointerPress(ui::PointerId pointer_id) {
return proxy_window_->IsHandlingPointerPressForTesting(pointer_id);
}
} // namespace ws

@@ -0,0 +1,31 @@
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_WS_PROXY_WINDOW_TEST_HELPER_H_
#define SERVICES_WS_PROXY_WINDOW_TEST_HELPER_H_
#include "base/macros.h"
#include "ui/events/event.h"
namespace ws {
class ProxyWindow;
// Used for accessing private members of ProxyWindow in tests.
class ProxyWindowTestHelper {
public:
explicit ProxyWindowTestHelper(ProxyWindow* proxy_window);
~ProxyWindowTestHelper();
bool IsHandlingPointerPress(ui::PointerId pointer_id);
private:
ProxyWindow* proxy_window_;
DISALLOW_COPY_AND_ASSIGN(ProxyWindowTestHelper);
};
} // namespace ws
#endif // SERVICES_WS_PROXY_WINDOW_TEST_HELPER_H_

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "services/ws/server_window.h" #include "services/ws/proxy_window.h"
#include <memory> #include <memory>
@@ -20,7 +20,7 @@
namespace ws { namespace ws {
TEST(ServerWindow, FindTargetForWindowWithEasyResizeTargeter) { TEST(ProxyWindow, FindTargetForWindowWithEasyResizeTargeter) {
WindowServiceTestSetup setup; WindowServiceTestSetup setup;
std::unique_ptr<wm::EasyResizeWindowTargeter> easy_resize_window_targeter = std::unique_ptr<wm::EasyResizeWindowTargeter> easy_resize_window_targeter =
std::make_unique<wm::EasyResizeWindowTargeter>( std::make_unique<wm::EasyResizeWindowTargeter>(
@@ -51,7 +51,7 @@ TEST(ServerWindow, FindTargetForWindowWithEasyResizeTargeter) {
setup.root(), &mouse_event2)); setup.root(), &mouse_event2));
} }
TEST(ServerWindow, FindTargetForWindowWithResizeInset) { TEST(ProxyWindow, FindTargetForWindowWithResizeInset) {
WindowServiceTestSetup setup; WindowServiceTestSetup setup;
aura::Window* top_level = aura::Window* top_level =
@@ -89,7 +89,7 @@ TEST(ServerWindow, FindTargetForWindowWithResizeInset) {
setup.root(), &mouse_event_2)); setup.root(), &mouse_event_2));
} }
TEST(ServerWindow, SetClientAreaPropagatesToClientSurfaceEmbedder) { TEST(ProxyWindow, SetClientAreaPropagatesToClientSurfaceEmbedder) {
WindowServiceTestSetup setup; WindowServiceTestSetup setup;
aura::Window* top_level = aura::Window* top_level =

@@ -1,20 +0,0 @@
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "services/ws/server_window_test_helper.h"
#include "services/ws/server_window.h"
namespace ws {
ServerWindowTestHelper::ServerWindowTestHelper(ServerWindow* server_window)
: server_window_(server_window) {}
ServerWindowTestHelper::~ServerWindowTestHelper() = default;
bool ServerWindowTestHelper::IsHandlingPointerPress(ui::PointerId pointer_id) {
return server_window_->IsHandlingPointerPressForTesting(pointer_id);
}
} // namespace ws

@@ -1,31 +0,0 @@
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_WS_SERVER_WINDOW_TEST_HELPER_H_
#define SERVICES_WS_SERVER_WINDOW_TEST_HELPER_H_
#include "base/macros.h"
#include "ui/events/event.h"
namespace ws {
class ServerWindow;
// Used for accessing private members of ServerWindow in tests.
class ServerWindowTestHelper {
public:
explicit ServerWindowTestHelper(ServerWindow* server_window);
~ServerWindowTestHelper();
bool IsHandlingPointerPress(ui::PointerId pointer_id);
private:
ServerWindow* server_window_;
DISALLOW_COPY_AND_ASSIGN(ServerWindowTestHelper);
};
} // namespace ws
#endif // SERVICES_WS_SERVER_WINDOW_TEST_HELPER_H_

@@ -5,7 +5,7 @@
#include "services/ws/window_delegate_impl.h" #include "services/ws/window_delegate_impl.h"
#include "services/ws/embedding.h" #include "services/ws/embedding.h"
#include "services/ws/server_window.h" #include "services/ws/proxy_window.h"
#include "services/ws/window_properties.h" #include "services/ws/window_properties.h"
#include "services/ws/window_tree.h" #include "services/ws/window_tree.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
@@ -32,23 +32,23 @@ gfx::NativeCursor WindowDelegateImpl::GetCursor(const gfx::Point& point) {
// Find the cursor of the embed root for an embedded Window, or the toplevel // Find the cursor of the embed root for an embedded Window, or the toplevel
// if it's not an embedded client. This is done to match the behavior of Aura, // if it's not an embedded client. This is done to match the behavior of Aura,
// which sets the cursor on the root. // which sets the cursor on the root.
for (ServerWindow* server_window = ServerWindow::GetMayBeNull(window_); for (ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window_);
server_window; server_window = ServerWindow::GetMayBeNull( proxy_window; proxy_window = ProxyWindow::GetMayBeNull(
server_window->window()->parent())) { proxy_window->window()->parent())) {
if (server_window->IsTopLevel()) { if (proxy_window->IsTopLevel()) {
if (server_window->window() == window_) if (proxy_window->window() == window_)
return server_window->cursor(); return proxy_window->cursor();
gfx::Point toplevel_point = point; gfx::Point toplevel_point = point;
aura::Window::ConvertPointToTarget(window_, server_window->window(), aura::Window::ConvertPointToTarget(window_, proxy_window->window(),
&toplevel_point); &toplevel_point);
return server_window->window()->delegate()->GetCursor(toplevel_point); return proxy_window->window()->delegate()->GetCursor(toplevel_point);
} }
// Assume that if the embedder is intercepting events, it's also responsible // Assume that if the embedder is intercepting events, it's also responsible
// for the cursor (which is the case with content embeddings). // for the cursor (which is the case with content embeddings).
if (server_window->HasEmbedding() && if (proxy_window->HasEmbedding() &&
!server_window->embedding()->embedding_tree_intercepts_events()) { !proxy_window->embedding()->embedding_tree_intercepts_events()) {
return server_window->cursor(); return proxy_window->cursor();
} }
} }
@@ -90,10 +90,10 @@ void WindowDelegateImpl::OnWindowTargetVisibilityChanged(bool visible) {}
void WindowDelegateImpl::OnWindowOcclusionChanged( void WindowDelegateImpl::OnWindowOcclusionChanged(
aura::Window::OcclusionState occlusion_state, aura::Window::OcclusionState occlusion_state,
const SkRegion&) { const SkRegion&) {
ServerWindow* const server_window = ServerWindow::GetMayBeNull(window_); ProxyWindow* const proxy_window = ProxyWindow::GetMayBeNull(window_);
// TODO: Send occluded region. // TODO: Send occluded region.
if (server_window) if (proxy_window)
server_window->owning_window_tree()->SendOcclusionState(window_); proxy_window->owning_window_tree()->SendOcclusionState(window_);
} }
bool WindowDelegateImpl::HasHitTestMask() const { bool WindowDelegateImpl::HasHitTestMask() const {

@@ -15,11 +15,11 @@
#include "services/ws/event_injector.h" #include "services/ws/event_injector.h"
#include "services/ws/event_queue.h" #include "services/ws/event_queue.h"
#include "services/ws/host_event_queue.h" #include "services/ws/host_event_queue.h"
#include "services/ws/proxy_window.h"
#include "services/ws/public/cpp/host/gpu_interface_provider.h" #include "services/ws/public/cpp/host/gpu_interface_provider.h"
#include "services/ws/public/mojom/window_manager.mojom.h" #include "services/ws/public/mojom/window_manager.mojom.h"
#include "services/ws/remoting_event_injector.h" #include "services/ws/remoting_event_injector.h"
#include "services/ws/screen_provider.h" #include "services/ws/screen_provider.h"
#include "services/ws/server_window.h"
#include "services/ws/user_activity_monitor.h" #include "services/ws/user_activity_monitor.h"
#include "services/ws/window_server_test_impl.h" #include "services/ws/window_server_test_impl.h"
#include "services/ws/window_service_delegate.h" #include "services/ws/window_service_delegate.h"
@@ -36,9 +36,9 @@ namespace ws {
namespace { namespace {
// Returns true if |window| has remote client and marked as has-content. // Returns true if |window| is a proxy window and marked as has-content.
bool IsRemoteOpaqueWindow(const aura::Window* window) { bool IsOpaqueProxyWindow(const aura::Window* window) {
return WindowService::HasRemoteClient(window) && return WindowService::IsProxyWindow(window) &&
window->GetProperty(aura::client::kClientWindowHasContent); window->GetProperty(aura::client::kClientWindowHasContent);
} }
@@ -77,7 +77,7 @@ WindowService::WindowService(
// Extends WindowOcclusionTracker to check whether remote window has content. // Extends WindowOcclusionTracker to check whether remote window has content.
env_->GetWindowOcclusionTracker()->set_window_has_content_callback( env_->GetWindowOcclusionTracker()->set_window_has_content_callback(
base::BindRepeating(&IsRemoteOpaqueWindow)); base::BindRepeating(&IsOpaqueProxyWindow));
} }
WindowService::~WindowService() { WindowService::~WindowService() {
@@ -95,17 +95,17 @@ void WindowService::BindServiceRequest(
service_binding_.Bind(std::move(request)); service_binding_.Bind(std::move(request));
} }
ServerWindow* WindowService::GetServerWindowForWindowCreateIfNecessary( ProxyWindow* WindowService::GetProxyWindowForWindowCreateIfNecessary(
aura::Window* window) { aura::Window* window) {
ServerWindow* server_window = ServerWindow::GetMayBeNull(window); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window);
if (server_window) if (proxy_window)
return server_window; return proxy_window;
const viz::FrameSinkId frame_sink_id = const viz::FrameSinkId frame_sink_id =
ClientWindowId(kWindowServerClientId, next_window_id_++); ClientWindowId(kWindowServerClientId, next_window_id_++);
CHECK_NE(0u, next_window_id_); CHECK_NE(0u, next_window_id_);
const bool is_top_level = false; const bool is_top_level = false;
return ServerWindow::Create(window, nullptr, frame_sink_id, is_top_level); return ProxyWindow::Create(window, nullptr, frame_sink_id, is_top_level);
} }
std::unique_ptr<WindowTree> WindowService::CreateWindowTree( std::unique_ptr<WindowTree> WindowService::CreateWindowTree(
@@ -133,14 +133,14 @@ void WindowService::SetDisplayForNewWindows(int64_t display_id) {
} }
// static // static
bool WindowService::HasRemoteClient(const aura::Window* window) { bool WindowService::IsProxyWindow(const aura::Window* window) {
return ServerWindow::GetMayBeNull(window); return ProxyWindow::GetMayBeNull(window);
} }
// static // static
bool WindowService::IsTopLevelWindow(const aura::Window* window) { bool WindowService::IsTopLevelWindow(const aura::Window* window) {
const ServerWindow* server_window = ServerWindow::GetMayBeNull(window); const ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window);
return server_window && server_window->IsTopLevel(); return proxy_window && proxy_window->IsTopLevel();
} }
aura::Window* WindowService::GetWindowByClientId(Id transport_id) { aura::Window* WindowService::GetWindowByClientId(Id transport_id) {
@@ -151,18 +151,18 @@ aura::Window* WindowService::GetWindowByClientId(Id transport_id) {
} }
Id WindowService::GetCompleteTransportIdForWindow(aura::Window* window) { Id WindowService::GetCompleteTransportIdForWindow(aura::Window* window) {
ServerWindow* server_window = ServerWindow::GetMayBeNull(window); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window);
if (!server_window) if (!proxy_window)
return kInvalidTransportId; return kInvalidTransportId;
if (!server_window->owning_window_tree()) if (!proxy_window->owning_window_tree())
return kInvalidTransportId; return kInvalidTransportId;
// NOTE: WindowTree::TransportIdForWindow() is the id sent to the client, // NOTE: WindowTree::TransportIdForWindow() is the id sent to the client,
// which has the client_id portion set to 0. This function wants to see the // which has the client_id portion set to 0. This function wants to see the
// real client_id, so it has to build it. // real client_id, so it has to build it.
return BuildTransportId( return BuildTransportId(
server_window->owning_window_tree()->client_id(), proxy_window->owning_window_tree()->client_id(),
ClientWindowIdFromTransportId( ClientWindowIdFromTransportId(
server_window->owning_window_tree()->TransportIdForWindow(window))); proxy_window->owning_window_tree()->TransportIdForWindow(window)));
} }
WindowService::TreeAndWindowId WindowService::TreeAndWindowId
@@ -188,7 +188,7 @@ bool WindowService::CompleteScheduleEmbedForExistingClient(
// Caller must supply a window, and further the window should not be exposed // Caller must supply a window, and further the window should not be exposed
// to a remote client yet. // to a remote client yet.
DCHECK(window); DCHECK(window);
DCHECK(!HasRemoteClient(window)); DCHECK(!IsProxyWindow(window));
const TreeAndWindowId tree_and_id = const TreeAndWindowId tree_and_id =
FindTreeWithScheduleEmbedForExistingClient(embed_token); FindTreeWithScheduleEmbedForExistingClient(embed_token);
@@ -199,14 +199,13 @@ bool WindowService::CompleteScheduleEmbedForExistingClient(
DCHECK(!(embed_flags & mojom::kEmbedFlagEmbedderInterceptsEvents)); DCHECK(!(embed_flags & mojom::kEmbedFlagEmbedderInterceptsEvents));
const bool owner_intercept_events = false; const bool owner_intercept_events = false;
ServerWindow* server_window = ProxyWindow* proxy_window = GetProxyWindowForWindowCreateIfNecessary(window);
GetServerWindowForWindowCreateIfNecessary(window);
tree_and_id.tree->CompleteScheduleEmbedForExistingClient( tree_and_id.tree->CompleteScheduleEmbedForExistingClient(
window, tree_and_id.id, embed_token); window, tree_and_id.id, embed_token);
std::unique_ptr<Embedding> embedding = std::unique_ptr<Embedding> embedding =
std::make_unique<Embedding>(nullptr, window, owner_intercept_events); std::make_unique<Embedding>(nullptr, window, owner_intercept_events);
embedding->InitForEmbedInExistingTree(tree_and_id.tree); embedding->InitForEmbedInExistingTree(tree_and_id.tree);
server_window->SetEmbedding(std::move(embedding)); proxy_window->SetEmbedding(std::move(embedding));
return true; return true;
} }
@@ -231,11 +230,11 @@ void WindowService::OnWillDestroyWindowTree(WindowTree* tree) {
} }
bool WindowService::RequestClose(aura::Window* window) { bool WindowService::RequestClose(aura::Window* window) {
ServerWindow* server_window = ServerWindow::GetMayBeNull(window); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window);
if (!server_window || !server_window->IsTopLevel()) if (!proxy_window || !proxy_window->IsTopLevel())
return false; return false;
server_window->owning_window_tree()->RequestClose(server_window); proxy_window->owning_window_tree()->RequestClose(proxy_window);
return true; return true;
} }
@@ -245,10 +244,10 @@ void WindowService::OnDisplayMetricsChanged(const display::Display& display,
} }
std::string WindowService::GetIdForDebugging(aura::Window* window) { std::string WindowService::GetIdForDebugging(aura::Window* window) {
ServerWindow* server_window = ServerWindow::GetMayBeNull(window); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window);
if (!server_window) if (!proxy_window)
return std::string(); return std::string();
return server_window->GetIdForDebugging(); return proxy_window->GetIdForDebugging();
} }
std::unique_ptr<HostEventQueue> WindowService::RegisterHostEventDispatcher( std::unique_ptr<HostEventQueue> WindowService::RegisterHostEventDispatcher(

@@ -65,7 +65,7 @@ class HostEventDispatcher;
class HostEventQueue; class HostEventQueue;
class RemotingEventInjector; class RemotingEventInjector;
class ScreenProvider; class ScreenProvider;
class ServerWindow; class ProxyWindow;
class UserActivityMonitor; class UserActivityMonitor;
class WindowServiceDelegate; class WindowServiceDelegate;
class WindowServiceObserver; class WindowServiceObserver;
@@ -93,8 +93,8 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowService
// Manger. // Manger.
void BindServiceRequest(service_manager::mojom::ServiceRequest request); void BindServiceRequest(service_manager::mojom::ServiceRequest request);
// Gets the ServerWindow for |window|, creating if necessary. // Gets the ProxyWindow for |window|, creating if necessary.
ServerWindow* GetServerWindowForWindowCreateIfNecessary(aura::Window* window); ProxyWindow* GetProxyWindowForWindowCreateIfNecessary(aura::Window* window);
// Creates a new WindowTree, caller must call one of the Init() functions on // Creates a new WindowTree, caller must call one of the Init() functions on
// the returned object. // the returned object.
@@ -110,8 +110,8 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowService
// over mojo to all remote clients. // over mojo to all remote clients.
void SetDisplayForNewWindows(int64_t display_id); void SetDisplayForNewWindows(int64_t display_id);
// Whether |window| hosts a remote client. // Returns true if |window| is a proxy window.
static bool HasRemoteClient(const aura::Window* window); static bool IsProxyWindow(const aura::Window* window);
// Returns true if |window| hosts a remote client and is a toplevel window. // Returns true if |window| hosts a remote client and is a toplevel window.
static bool IsTopLevelWindow(const aura::Window* window); static bool IsTopLevelWindow(const aura::Window* window);
@@ -179,7 +179,7 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowService
aura::WindowTreeHost* window_tree_host, aura::WindowTreeHost* window_tree_host,
HostEventDispatcher* dispatcher); HostEventDispatcher* dispatcher);
// Returns an id useful for debugging. See ServerWindow::GetIdForDebugging() // Returns an id useful for debugging. See ProxyWindow::GetIdForDebugging()
// for details. // for details.
std::string GetIdForDebugging(aura::Window* window); std::string GetIdForDebugging(aura::Window* window);

@@ -200,7 +200,7 @@ TEST(WindowServiceTest, ScheduleEmbedForExistingClientUsingLocalWindow) {
local_window->Init(ui::LAYER_NOT_DRAWN); local_window->Init(ui::LAYER_NOT_DRAWN);
ASSERT_TRUE(setup.service()->CompleteScheduleEmbedForExistingClient( ASSERT_TRUE(setup.service()->CompleteScheduleEmbedForExistingClient(
local_window.get(), token, /* embed_flags */ 0)); local_window.get(), token, /* embed_flags */ 0));
EXPECT_TRUE(WindowService::HasRemoteClient(local_window.get())); EXPECT_TRUE(WindowService::IsProxyWindow(local_window.get()));
} }
TEST(WindowServiceTest, TEST(WindowServiceTest,
@@ -227,11 +227,11 @@ TEST(WindowServiceTest,
local_window->Init(ui::LAYER_NOT_DRAWN); local_window->Init(ui::LAYER_NOT_DRAWN);
ASSERT_TRUE(setup.service()->CompleteScheduleEmbedForExistingClient( ASSERT_TRUE(setup.service()->CompleteScheduleEmbedForExistingClient(
local_window.get(), token, /* embed_flags */ 0)); local_window.get(), token, /* embed_flags */ 0));
EXPECT_TRUE(WindowService::HasRemoteClient(local_window.get())); EXPECT_TRUE(WindowService::IsProxyWindow(local_window.get()));
// Deleting |window_tree2| should remove the remote client. // Deleting |window_tree2| should make |local_window| no longer a proxy.
window_tree2.reset(); window_tree2.reset();
EXPECT_FALSE(WindowService::HasRemoteClient(local_window.get())); EXPECT_FALSE(WindowService::IsProxyWindow(local_window.get()));
} }
} // namespace ws } // namespace ws

@@ -21,8 +21,8 @@
#include "services/ws/drag_drop_delegate.h" #include "services/ws/drag_drop_delegate.h"
#include "services/ws/embedding.h" #include "services/ws/embedding.h"
#include "services/ws/event_observer_helper.h" #include "services/ws/event_observer_helper.h"
#include "services/ws/proxy_window.h"
#include "services/ws/public/cpp/property_type_converters.h" #include "services/ws/public/cpp/property_type_converters.h"
#include "services/ws/server_window.h"
#include "services/ws/topmost_window_observer.h" #include "services/ws/topmost_window_observer.h"
#include "services/ws/window_delegate_impl.h" #include "services/ws/window_delegate_impl.h"
#include "services/ws/window_manager_interface.h" #include "services/ws/window_manager_interface.h"
@@ -128,10 +128,10 @@ WindowTree::~WindowTree() {
void WindowTree::InitForEmbed(aura::Window* root, void WindowTree::InitForEmbed(aura::Window* root,
mojom::WindowTreePtr window_tree_ptr) { mojom::WindowTreePtr window_tree_ptr) {
// Force ServerWindow to be created for |root|. // Force ProxyWindow to be created for |root|.
ServerWindow* server_window = ProxyWindow* proxy_window =
window_service_->GetServerWindowForWindowCreateIfNecessary(root); window_service_->GetProxyWindowForWindowCreateIfNecessary(root);
const ClientWindowId client_window_id = server_window->frame_sink_id(); const ClientWindowId client_window_id = proxy_window->frame_sink_id();
AddWindowToKnownWindows(root, client_window_id, nullptr); AddWindowToKnownWindows(root, client_window_id, nullptr);
const bool is_top_level = false; const bool is_top_level = false;
ClientRoot* client_root = CreateClientRoot(root, is_top_level); ClientRoot* client_root = CreateClientRoot(root, is_top_level);
@@ -144,11 +144,11 @@ void WindowTree::InitForEmbed(aura::Window* root,
window_tree_client_->OnEmbed(WindowToWindowData(root), window_tree_client_->OnEmbed(WindowToWindowData(root),
std::move(window_tree_ptr), display_id, std::move(window_tree_ptr), display_id,
ClientWindowIdToTransportId(focused_window_id), ClientWindowIdToTransportId(focused_window_id),
drawn, server_window->local_surface_id()); drawn, proxy_window->local_surface_id());
// Reset the frame sink id locally (after calling OnEmbed()). This is // Reset the frame sink id locally (after calling OnEmbed()). This is
// needed so that the id used by the client matches the id used locally. // needed so that the id used by the client matches the id used locally.
server_window->set_frame_sink_id(ClientWindowId(client_id_, 0)); proxy_window->set_frame_sink_id(ClientWindowId(client_id_, 0));
client_root->RegisterVizEmbeddingSupport(); client_root->RegisterVizEmbeddingSupport();
} }
@@ -160,7 +160,7 @@ void WindowTree::InitFromFactory() {
void WindowTree::SendEventToClient(aura::Window* window, void WindowTree::SendEventToClient(aura::Window* window,
const ui::Event& event) { const ui::Event& event) {
// As gesture recognition runs in the client, GestureEvents should not be // As gesture recognition runs in the client, GestureEvents should not be
// forwarded. ServerWindow's event processing should ensure no GestureEvents // forwarded. ProxyWindow's event processing should ensure no GestureEvents
// are sent. // are sent.
DCHECK(!event.IsGestureEvent()); DCHECK(!event.IsGestureEvent());
@@ -211,7 +211,7 @@ void WindowTree::SendEventToClient(aura::Window* window,
} }
} }
DVLOG(4) << "SendEventToClient window=" DVLOG(4) << "SendEventToClient window="
<< ServerWindow::GetMayBeNull(window)->GetIdForDebugging() << ProxyWindow::GetMayBeNull(window)->GetIdForDebugging()
<< " event_type=" << ui::EventTypeName(event.type()) << " event_type=" << ui::EventTypeName(event.type())
<< " event_id=" << event_id; << " event_id=" << event_id;
window_tree_client_->OnWindowInputEvent( window_tree_client_->OnWindowInputEvent(
@@ -250,7 +250,7 @@ aura::Window* WindowTree::GetWindowByTransportId(Id transport_window_id) {
return GetWindowByClientId(MakeClientWindowId(transport_window_id)); return GetWindowByClientId(MakeClientWindowId(transport_window_id));
} }
void WindowTree::RequestClose(ServerWindow* window) { void WindowTree::RequestClose(ProxyWindow* window) {
DCHECK(window->IsTopLevel()); DCHECK(window->IsTopLevel());
DCHECK_EQ(this, window->owning_window_tree()); DCHECK_EQ(this, window->owning_window_tree());
window_tree_client_->RequestClose(TransportIdForWindow(window->window())); window_tree_client_->RequestClose(TransportIdForWindow(window->window()));
@@ -288,26 +288,26 @@ void WindowTree::CompleteScheduleEmbedForExistingClient(
const bool is_top_level = false; const bool is_top_level = false;
ClientRoot* client_root = CreateClientRoot(window, is_top_level); ClientRoot* client_root = CreateClientRoot(window, is_top_level);
ServerWindow* server_window = ServerWindow::GetMayBeNull(window); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window);
// It's expected we only get here if a ServerWindow exists for |window|. // It's expected we only get here if a ProxyWindow exists for |window|.
DCHECK(server_window); DCHECK(proxy_window);
const int64_t display_id = const int64_t display_id =
display::Screen::GetScreen()->GetDisplayNearestWindow(window).id(); display::Screen::GetScreen()->GetDisplayNearestWindow(window).id();
window_tree_client_->OnEmbedFromToken(token, WindowToWindowData(window), window_tree_client_->OnEmbedFromToken(token, WindowToWindowData(window),
display_id, display_id,
server_window->local_surface_id()); proxy_window->local_surface_id());
// Reset the frame sink id locally (after calling OnEmbedFromToken()). This is // Reset the frame sink id locally (after calling OnEmbedFromToken()). This is
// needed so that the id used by the client matches the id used locally. // needed so that the id used by the client matches the id used locally.
server_window->set_frame_sink_id(id); proxy_window->set_frame_sink_id(id);
client_root->RegisterVizEmbeddingSupport(); client_root->RegisterVizEmbeddingSupport();
} }
bool WindowTree::HasAtLeastOneRootWithCompositorFrameSink() { bool WindowTree::HasAtLeastOneRootWithCompositorFrameSink() {
for (auto& client_root : client_roots_) { for (auto& client_root : client_roots_) {
if (ServerWindow::GetMayBeNull(client_root->window()) if (ProxyWindow::GetMayBeNull(client_root->window())
->attached_compositor_frame_sink()) { ->attached_compositor_frame_sink()) {
return true; return true;
} }
@@ -340,11 +340,11 @@ ClientRoot* WindowTree::CreateClientRoot(aura::Window* window,
DCHECK(window); DCHECK(window);
// Only one client may be embedded in a window at a time. // Only one client may be embedded in a window at a time.
ServerWindow* server_window = ProxyWindow* proxy_window =
window_service_->GetServerWindowForWindowCreateIfNecessary(window); window_service_->GetProxyWindowForWindowCreateIfNecessary(window);
if (server_window->embedded_window_tree()) { if (proxy_window->embedded_window_tree()) {
server_window->embedded_window_tree()->DeleteClientRootWithRoot(window); proxy_window->embedded_window_tree()->DeleteClientRootWithRoot(window);
DCHECK(!server_window->embedded_window_tree()); DCHECK(!proxy_window->embedded_window_tree());
} }
// Because a new client is being embedded all existing children are removed. // Because a new client is being embedded all existing children are removed.
@@ -362,12 +362,12 @@ void WindowTree::DeleteClientRoot(ClientRoot* client_root,
DeleteClientRootReason reason) { DeleteClientRootReason reason) {
aura::Window* window = client_root->window(); aura::Window* window = client_root->window();
ServerWindow* server_window = ServerWindow::GetMayBeNull(window); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window);
client_root->UnattachChildFrameSinkIdRecursive(server_window); client_root->UnattachChildFrameSinkIdRecursive(proxy_window);
if (server_window->capture_owner() == this) { if (proxy_window->capture_owner() == this) {
// This client will no longer know about |window|, so it should not receive // This client will no longer know about |window|, so it should not receive
// any events sent to the client. // any events sent to the client.
server_window->SetCaptureOwner(nullptr); proxy_window->SetCaptureOwner(nullptr);
} }
// Delete the ClientRoot first, so that we don't attempt to spam the // Delete the ClientRoot first, so that we don't attempt to spam the
@@ -407,25 +407,24 @@ void WindowTree::DeleteClientRoot(ClientRoot* client_root,
if (reason == DeleteClientRootReason::kUnembed || if (reason == DeleteClientRootReason::kUnembed ||
reason == DeleteClientRootReason::kDestructor) { reason == DeleteClientRootReason::kDestructor) {
// Notify the owner of the window it no longer has a client embedded in it. // Notify the owner of the window it no longer has a client embedded in it.
ServerWindow* server_window = ServerWindow::GetMayBeNull(window); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window);
if (server_window->owning_window_tree() && if (proxy_window->owning_window_tree() &&
server_window->owning_window_tree() != this) { proxy_window->owning_window_tree() != this) {
// ClientRoots always trigger creation of a ServerWindow, so // ClientRoots always trigger creation of a ProxyWindow, so
// |server_window| must exist at this point. // |proxy_window| must exist at this point.
DCHECK(server_window); DCHECK(proxy_window);
server_window->owning_window_tree() proxy_window->owning_window_tree()
->window_tree_client_->OnEmbeddedAppDisconnected( ->window_tree_client_->OnEmbeddedAppDisconnected(
server_window->owning_window_tree()->TransportIdForWindow( proxy_window->owning_window_tree()->TransportIdForWindow(window));
window));
} }
if (server_window->embedding()) if (proxy_window->embedding())
server_window->embedding()->clear_embedded_tree(); proxy_window->embedding()->clear_embedded_tree();
// Only reset the embedding if it's for an existing tree. To do otherwise // Only reset the embedding if it's for an existing tree. To do otherwise
// results in trying to delete this. // results in trying to delete this.
if (server_window->embedding() && !server_window->embedding()->binding()) { if (proxy_window->embedding() && !proxy_window->embedding()->binding()) {
server_window->SetEmbedding(nullptr); proxy_window->SetEmbedding(nullptr);
if (!server_window->owning_window_tree()) if (!proxy_window->owning_window_tree())
server_window->Destroy(); proxy_window->Destroy();
} }
} }
} }
@@ -474,17 +473,17 @@ WindowTree::ClientRoots::iterator WindowTree::FindClientRootWithRoot(
} }
bool WindowTree::IsWindowRootOfAnotherClient(aura::Window* window) const { bool WindowTree::IsWindowRootOfAnotherClient(aura::Window* window) const {
ServerWindow* server_window = ServerWindow::GetMayBeNull(window); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window);
return server_window && server_window->embedded_window_tree() != nullptr && return proxy_window && proxy_window->embedded_window_tree() != nullptr &&
server_window->embedded_window_tree() != this; proxy_window->embedded_window_tree() != this;
} }
bool WindowTree::DoesAnyAncestorInterceptEvents(ServerWindow* window) { bool WindowTree::DoesAnyAncestorInterceptEvents(ProxyWindow* window) {
if (window->embedding() && window->embedding()->embedding_tree() != this && if (window->embedding() && window->embedding()->embedding_tree() != this &&
window->embedding()->embedding_tree_intercepts_events()) { window->embedding()->embedding_tree_intercepts_events()) {
return true; return true;
} }
ServerWindow* parent = ServerWindow::GetMayBeNull(window->window()->parent()); ProxyWindow* parent = ProxyWindow::GetMayBeNull(window->window()->parent());
return parent && DoesAnyAncestorInterceptEvents(parent); return parent && DoesAnyAncestorInterceptEvents(parent);
} }
@@ -559,7 +558,7 @@ aura::Window* WindowTree::AddClientCreatedWindow(
bool is_top_level, bool is_top_level,
std::unique_ptr<aura::Window> window_ptr) { std::unique_ptr<aura::Window> window_ptr) {
aura::Window* window = window_ptr.get(); aura::Window* window = window_ptr.get();
ServerWindow::Create(window, this, id, is_top_level); ProxyWindow::Create(window, this, id, is_top_level);
AddWindowToKnownWindows(window, id, std::move(window_ptr)); AddWindowToKnownWindows(window, id, std::move(window_ptr));
return window; return window;
} }
@@ -584,12 +583,12 @@ void WindowTree::RemoveWindowFromKnownWindows(aura::Window* window,
bool delete_if_owned) { bool delete_if_owned) {
DCHECK(IsWindowKnown(window)); DCHECK(IsWindowKnown(window));
ServerWindow* server_window = ServerWindow::GetMayBeNull(window); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window);
ClientRoot* client_root = FindClientRootContaining(window); ClientRoot* client_root = FindClientRootContaining(window);
if (client_root) if (client_root)
client_root->UnattachChildFrameSinkIdRecursive(server_window); client_root->UnattachChildFrameSinkIdRecursive(proxy_window);
server_window->set_attached_frame_sink_id(viz::FrameSinkId()); proxy_window->set_attached_frame_sink_id(viz::FrameSinkId());
auto iter = known_windows_map_.find(window); auto iter = known_windows_map_.find(window);
DCHECK(iter != known_windows_map_.end()); DCHECK(iter != known_windows_map_.end());
@@ -606,7 +605,7 @@ void WindowTree::RemoveWindowFromKnownWindows(aura::Window* window,
DCHECK(iter == known_windows_map_.find(window)); DCHECK(iter == known_windows_map_.find(window));
// Remove from these maps after destruction. This is necessary as destruction // Remove from these maps after destruction. This is necessary as destruction
// may end up expecting to find a ServerWindow. // may end up expecting to find a ProxyWindow.
DCHECK(iter != known_windows_map_.end()); DCHECK(iter != known_windows_map_.end());
client_window_id_to_window_map_.erase(iter->second.client_window_id); client_window_id_to_window_map_.erase(iter->second.client_window_id);
known_windows_map_.erase(iter); known_windows_map_.erase(iter);
@@ -707,9 +706,8 @@ WindowTree::GetAndRemoveScheduledEmbedWindowTreeClient(
visited_trees->insert(this); visited_trees->insert(this);
for (auto& client_root : client_roots_) { for (auto& client_root : client_roots_) {
ServerWindow* root_window = ProxyWindow* root_window = ProxyWindow::GetMayBeNull(client_root->window());
ServerWindow::GetMayBeNull(client_root->window()); DCHECK(root_window); // There should always be a ProxyWindow for a root.
DCHECK(root_window); // There should always be a ServerWindow for a root.
WindowTree* owning_tree = root_window->owning_window_tree(); WindowTree* owning_tree = root_window->owning_window_tree();
if (owning_tree) { if (owning_tree) {
auto result = owning_tree->GetAndRemoveScheduledEmbedWindowTreeClient( auto result = owning_tree->GetAndRemoveScheduledEmbedWindowTreeClient(
@@ -814,9 +812,9 @@ bool WindowTree::SetCaptureImpl(const ClientWindowId& window_id) {
return false; return false;
} }
ServerWindow* server_window = ServerWindow::GetMayBeNull(window); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window);
if (DoesAnyAncestorInterceptEvents(server_window)) { if (DoesAnyAncestorInterceptEvents(proxy_window)) {
// If an ancestor is intercepting events, than the descendants are not // If an ancestor is intercepting events, than the descendants are not
// allowed to set capture. This is primarily to prevent renderers from // allowed to set capture. This is primarily to prevent renderers from
// setting capture. // setting capture.
@@ -828,20 +826,20 @@ bool WindowTree::SetCaptureImpl(const ClientWindowId& window_id) {
DCHECK(capture_controller); DCHECK(capture_controller);
if (capture_controller->GetCaptureWindow() == window) { if (capture_controller->GetCaptureWindow() == window) {
if (server_window->capture_owner() != this) { if (proxy_window->capture_owner() != this) {
// The capture window didn't change, but the client that owns capture // The capture window didn't change, but the client that owns capture
// changed (see |ServerWindow::capture_owner_| for details on this). // changed (see |ProxyWindow::capture_owner_| for details on this).
// Notify the current owner that it lost capture. // Notify the current owner that it lost capture.
if (server_window->capture_owner()) if (proxy_window->capture_owner())
server_window->capture_owner()->OnCaptureLost(window); proxy_window->capture_owner()->OnCaptureLost(window);
server_window->SetCaptureOwner(this); proxy_window->SetCaptureOwner(this);
} }
return true; return true;
} }
ClientChange change(property_change_tracker_.get(), window, ClientChange change(property_change_tracker_.get(), window,
ClientChangeType::kCapture); ClientChangeType::kCapture);
server_window->SetCaptureOwner(this); proxy_window->SetCaptureOwner(this);
capture_controller->SetCapture(window); capture_controller->SetCapture(window);
return capture_controller->GetCaptureWindow() == window; return capture_controller->GetCaptureWindow() == window;
} }
@@ -870,14 +868,13 @@ bool WindowTree::ReleaseCaptureImpl(const ClientWindowId& window_id) {
return false; return false;
} }
ServerWindow* server_window = ServerWindow::GetMayBeNull(window); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window);
if (server_window->capture_owner() && if (proxy_window->capture_owner() && proxy_window->capture_owner() != this) {
server_window->capture_owner() != this) {
// This client is trying to release capture, but it doesn't own capture. // This client is trying to release capture, but it doesn't own capture.
DVLOG(1) << "ReleaseCapture failed (client did not request capture)"; DVLOG(1) << "ReleaseCapture failed (client did not request capture)";
return false; return false;
} }
server_window->SetCaptureOwner(nullptr); proxy_window->SetCaptureOwner(nullptr);
ClientChange change(property_change_tracker_.get(), window, ClientChange change(property_change_tracker_.get(), window,
ClientChangeType::kCapture); ClientChangeType::kCapture);
@@ -1126,10 +1123,10 @@ bool WindowTree::EmbedImpl(const ClientWindowId& window_id,
base::Unretained(this), embedding.get())); base::Unretained(this), embedding.get()));
if (flags & mojom::kEmbedFlagEmbedderControlsVisibility) if (flags & mojom::kEmbedFlagEmbedderControlsVisibility)
embedding->embedded_tree()->can_change_root_window_visibility_ = false; embedding->embedded_tree()->can_change_root_window_visibility_ = false;
ServerWindow* server_window = ServerWindow::GetMayBeNull(window); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window);
server_window->SetEmbedding(std::move(embedding)); proxy_window->SetEmbedding(std::move(embedding));
window_tree_client_->OnFrameSinkIdAllocated( window_tree_client_->OnFrameSinkIdAllocated(
ClientWindowIdToTransportId(window_id), server_window->frame_sink_id()); ClientWindowIdToTransportId(window_id), proxy_window->frame_sink_id());
return true; return true;
} }
@@ -1170,11 +1167,11 @@ bool WindowTree::SetWindowBoundsImpl(
return false; return false;
} }
ServerWindow* server_window = ServerWindow::GetMayBeNull(window); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window);
const gfx::Rect original_bounds = const gfx::Rect original_bounds =
IsTopLevel(window) ? window->GetBoundsInScreen() : window->bounds(); IsTopLevel(window) ? window->GetBoundsInScreen() : window->bounds();
const bool local_surface_id_changed = const bool local_surface_id_changed =
server_window->local_surface_id() != local_surface_id; proxy_window->local_surface_id() != local_surface_id;
if (original_bounds == bounds && !local_surface_id_changed) if (original_bounds == bounds && !local_surface_id_changed)
return true; return true;
@@ -1183,7 +1180,7 @@ bool WindowTree::SetWindowBoundsImpl(
ClientChangeType::kBounds); ClientChangeType::kBounds);
if (IsLocalSurfaceIdAssignedByClient(window)) if (IsLocalSurfaceIdAssignedByClient(window))
server_window->set_local_surface_id(local_surface_id); proxy_window->set_local_surface_id(local_surface_id);
if (IsTopLevel(window)) { if (IsTopLevel(window)) {
display::Display dst_display = display::Display dst_display =
@@ -1208,9 +1205,9 @@ bool WindowTree::SetWindowBoundsImpl(
if (local_surface_id_changed) { if (local_surface_id_changed) {
// If the bounds didn't change, but the LocalSurfaceId did, then the // If the bounds didn't change, but the LocalSurfaceId did, then the
// LocalSurfaceId needs to be propagated to any embeddings. // LocalSurfaceId needs to be propagated to any embeddings.
if (server_window->HasEmbedding() && if (proxy_window->HasEmbedding() &&
server_window->embedding()->embedding_tree() == this) { proxy_window->embedding()->embedding_tree() == this) {
WindowTree* embedded_tree = server_window->embedding()->embedded_tree(); WindowTree* embedded_tree = proxy_window->embedding()->embedded_tree();
ClientRoot* embedded_client_root = ClientRoot* embedded_client_root =
embedded_tree->GetClientRootForWindow(window); embedded_tree->GetClientRootForWindow(window);
DCHECK(embedded_client_root); DCHECK(embedded_client_root);
@@ -1221,7 +1218,7 @@ bool WindowTree::SetWindowBoundsImpl(
} }
if (window->bounds() == bounds && if (window->bounds() == bounds &&
server_window->local_surface_id() == local_surface_id) { proxy_window->local_surface_id() == local_surface_id) {
return true; return true;
} }
@@ -1283,7 +1280,7 @@ bool WindowTree::SetCursorImpl(const ClientWindowId& window_id,
return false; return false;
} }
auto* server_window = ServerWindow::GetMayBeNull(window); auto* proxy_window = ProxyWindow::GetMayBeNull(window);
ui::Cursor old_cursor_type = cursor.ToNativeCursor(); ui::Cursor old_cursor_type = cursor.ToNativeCursor();
@@ -1292,9 +1289,9 @@ bool WindowTree::SetCursorImpl(const ClientWindowId& window_id,
// last to have set the cursor/is currently hovered). // last to have set the cursor/is currently hovered).
if (!window_service_->delegate()->StoreAndSetCursor(window, if (!window_service_->delegate()->StoreAndSetCursor(window,
old_cursor_type)) { old_cursor_type)) {
// Store the cursor on ServerWindow. This will later be accessed by the // Store the cursor on ProxyWindow. This will later be accessed by the
// WindowDelegate for non-toplevels, i.e. WindowDelegateImpl. // WindowDelegate for non-toplevels, i.e. WindowDelegateImpl.
server_window->StoreCursor(old_cursor_type); proxy_window->StoreCursor(old_cursor_type);
} }
return true; return true;
@@ -1343,7 +1340,7 @@ void WindowTree::GetWindowTreeRecursive(aura::Window* window,
} }
void WindowTree::OnEmbeddedClientConnectionLost(Embedding* embedding) { void WindowTree::OnEmbeddedClientConnectionLost(Embedding* embedding) {
ServerWindow::GetMayBeNull(embedding->window())->SetEmbedding(nullptr); ProxyWindow::GetMayBeNull(embedding->window())->SetEmbedding(nullptr);
} }
void WindowTree::OnWindowHierarchyChanging( void WindowTree::OnWindowHierarchyChanging(
@@ -1351,17 +1348,17 @@ void WindowTree::OnWindowHierarchyChanging(
if (params.target != params.receiver || !IsClientCreatedWindow(params.target)) if (params.target != params.receiver || !IsClientCreatedWindow(params.target))
return; return;
ServerWindow* server_window = ServerWindow::GetMayBeNull(params.target); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(params.target);
DCHECK(server_window); // non-null because of IsClientCreatedWindow() check. DCHECK(proxy_window); // non-null because of IsClientCreatedWindow() check.
ClientRoot* old_root = FindClientRootContaining(params.old_parent); ClientRoot* old_root = FindClientRootContaining(params.old_parent);
ClientRoot* new_root = FindClientRootContaining(params.new_parent); ClientRoot* new_root = FindClientRootContaining(params.new_parent);
if (old_root == new_root) if (old_root == new_root)
return; return;
if (old_root) if (old_root)
old_root->UnattachChildFrameSinkIdRecursive(server_window); old_root->UnattachChildFrameSinkIdRecursive(proxy_window);
if (new_root) if (new_root)
new_root->AttachChildFrameSinkIdRecursive(server_window); new_root->AttachChildFrameSinkIdRecursive(proxy_window);
} }
void WindowTree::OnWindowDestroyed(aura::Window* window) { void WindowTree::OnWindowDestroyed(aura::Window* window) {
@@ -1410,12 +1407,12 @@ void WindowTree::OnCaptureChanged(aura::Window* lost_capture,
// another window. // another window.
if (lost_capture && (IsClientCreatedWindow(lost_capture) || if (lost_capture && (IsClientCreatedWindow(lost_capture) ||
IsClientRootWindow(lost_capture))) { IsClientRootWindow(lost_capture))) {
ServerWindow* server_window = ServerWindow::GetMayBeNull(lost_capture); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(lost_capture);
if (server_window->capture_owner() == this) { if (proxy_window->capture_owner() == this) {
// One of the windows known to this client had capture. Notify the client // One of the windows known to this client had capture. Notify the client
// of the change. If the client does not know about the window that gained // of the change. If the client does not know about the window that gained
// capture, an invalid window id is used. // capture, an invalid window id is used.
server_window->SetCaptureOwner(nullptr); proxy_window->SetCaptureOwner(nullptr);
const Id gained_capture_id = gained_capture && const Id gained_capture_id = gained_capture &&
IsWindowKnown(gained_capture) && IsWindowKnown(gained_capture) &&
!IsClientRootWindow(gained_capture) !IsClientRootWindow(gained_capture)
@@ -1472,8 +1469,8 @@ void WindowTree::NewTopLevelWindow(
const bool is_top_level = true; const bool is_top_level = true;
aura::Window* top_level = AddClientCreatedWindow( aura::Window* top_level = AddClientCreatedWindow(
client_window_id, is_top_level, std::move(top_level_ptr)); client_window_id, is_top_level, std::move(top_level_ptr));
ServerWindow* top_level_server_window = ServerWindow::GetMayBeNull(top_level); ProxyWindow* top_level_proxy_window = ProxyWindow::GetMayBeNull(top_level);
top_level_server_window->set_frame_sink_id(client_window_id); top_level_proxy_window->set_frame_sink_id(client_window_id);
const int64_t display_id = const int64_t display_id =
display::Screen::GetScreen()->GetDisplayNearestWindow(top_level).id(); display::Screen::GetScreen()->GetDisplayNearestWindow(top_level).id();
// This passes null for the mojom::WindowTreePtr because the client has // This passes null for the mojom::WindowTreePtr because the client has
@@ -1482,7 +1479,7 @@ void WindowTree::NewTopLevelWindow(
CreateClientRoot(top_level, is_top_level)->RegisterVizEmbeddingSupport(); CreateClientRoot(top_level, is_top_level)->RegisterVizEmbeddingSupport();
window_tree_client_->OnTopLevelCreated( window_tree_client_->OnTopLevelCreated(
change_id, WindowToWindowData(top_level), display_id, change_id, WindowToWindowData(top_level), display_id,
top_level->IsVisible(), top_level_server_window->local_surface_id()); top_level->IsVisible(), top_level_proxy_window->local_surface_id());
} }
void WindowTree::DeleteWindow(uint32_t change_id, Id transport_window_id) { void WindowTree::DeleteWindow(uint32_t change_id, Id transport_window_id) {
@@ -1550,9 +1547,9 @@ void WindowTree::SetClientArea(
return; return;
} }
ServerWindow* server_window = ServerWindow::GetMayBeNull(window); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window);
DCHECK(server_window); // Must exist because of preceding conditionals. DCHECK(proxy_window); // Must exist because of preceding conditionals.
server_window->SetClientArea( proxy_window->SetClientArea(
insets, additional_client_areas.value_or(std::vector<gfx::Rect>())); insets, additional_client_areas.value_or(std::vector<gfx::Rect>()));
} }
@@ -1572,10 +1569,10 @@ void WindowTree::SetHitTestInsets(Id transport_window_id,
return; return;
} }
ServerWindow* server_window = ServerWindow::GetMayBeNull(window); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window);
DCHECK(server_window); // Must exist because of preceding conditionals. DCHECK(proxy_window); // Must exist because of preceding conditionals.
server_window->SetHitTestInsets(MakeInsetsPositive(mouse), proxy_window->SetHitTestInsets(MakeInsetsPositive(mouse),
MakeInsetsPositive(touch)); MakeInsetsPositive(touch));
} }
void WindowTree::AttachFrameSinkId(Id transport_window_id, void WindowTree::AttachFrameSinkId(Id transport_window_id,
@@ -1590,18 +1587,18 @@ void WindowTree::AttachFrameSinkId(Id transport_window_id,
DVLOG(3) << "AttachFrameSinkId failed (invalid window id)"; DVLOG(3) << "AttachFrameSinkId failed (invalid window id)";
return; return;
} }
ServerWindow* server_window = ServerWindow::GetMayBeNull(window); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window);
DCHECK(server_window); // Must exist because of preceding conditionals. DCHECK(proxy_window); // Must exist because of preceding conditionals.
if (server_window->attached_frame_sink_id() == f) if (proxy_window->attached_frame_sink_id() == f)
return; return;
if (f.is_valid() && server_window->attached_frame_sink_id().is_valid()) { if (f.is_valid() && proxy_window->attached_frame_sink_id().is_valid()) {
DVLOG(3) << "AttachFrameSinkId failed (window already has frame sink)"; DVLOG(3) << "AttachFrameSinkId failed (window already has frame sink)";
return; return;
} }
server_window->set_attached_frame_sink_id(f); proxy_window->set_attached_frame_sink_id(f);
ClientRoot* client_root = FindClientRootContaining(window); ClientRoot* client_root = FindClientRootContaining(window);
if (client_root) if (client_root)
client_root->AttachChildFrameSinkId(server_window); client_root->AttachChildFrameSinkId(proxy_window);
} }
void WindowTree::UnattachFrameSinkId(Id transport_window_id) { void WindowTree::UnattachFrameSinkId(Id transport_window_id) {
@@ -1611,17 +1608,17 @@ void WindowTree::UnattachFrameSinkId(Id transport_window_id) {
DVLOG(3) << "UnattachFrameSinkId failed (invalid window id)"; DVLOG(3) << "UnattachFrameSinkId failed (invalid window id)";
return; return;
} }
ServerWindow* server_window = ServerWindow::GetMayBeNull(window); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window);
DCHECK(server_window); // Must exist because of preceding conditionals. DCHECK(proxy_window); // Must exist because of preceding conditionals.
if (!server_window->attached_frame_sink_id().is_valid()) { if (!proxy_window->attached_frame_sink_id().is_valid()) {
DVLOG(3) << "UnattachFrameSinkId failed (frame sink already cleared)"; DVLOG(3) << "UnattachFrameSinkId failed (frame sink already cleared)";
return; return;
} }
ClientRoot* client_root = FindClientRootContaining(window); ClientRoot* client_root = FindClientRootContaining(window);
if (client_root) if (client_root)
client_root->UnattachChildFrameSinkId(server_window); client_root->UnattachChildFrameSinkId(proxy_window);
server_window->set_attached_frame_sink_id(viz::FrameSinkId()); proxy_window->set_attached_frame_sink_id(viz::FrameSinkId());
} }
void WindowTree::SetCanAcceptDrops(Id window_id, bool accepts_drops) { void WindowTree::SetCanAcceptDrops(Id window_id, bool accepts_drops) {
@@ -1635,16 +1632,16 @@ void WindowTree::SetCanAcceptDrops(Id window_id, bool accepts_drops) {
return; return;
} }
ServerWindow* server_window = ServerWindow::GetMayBeNull(window); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window);
DCHECK(server_window); // Must exist because of preceding conditionals. DCHECK(proxy_window); // Must exist because of preceding conditionals.
if (accepts_drops && !server_window->HasDragDropDelegate()) { if (accepts_drops && !proxy_window->HasDragDropDelegate()) {
auto drag_drop_delegate = std::make_unique<DragDropDelegate>( auto drag_drop_delegate = std::make_unique<DragDropDelegate>(
window_tree_client_, window, window_id); window_tree_client_, window, window_id);
aura::client::SetDragDropDelegate(window, drag_drop_delegate.get()); aura::client::SetDragDropDelegate(window, drag_drop_delegate.get());
server_window->SetDragDropDelegate(std::move(drag_drop_delegate)); proxy_window->SetDragDropDelegate(std::move(drag_drop_delegate));
} else if (!accepts_drops && server_window->HasDragDropDelegate()) { } else if (!accepts_drops && proxy_window->HasDragDropDelegate()) {
aura::client::SetDragDropDelegate(window, nullptr); aura::client::SetDragDropDelegate(window, nullptr);
server_window->SetDragDropDelegate(nullptr); proxy_window->SetDragDropDelegate(nullptr);
} }
} }
@@ -1685,19 +1682,19 @@ void WindowTree::AttachCompositorFrameSink(
DVLOG(1) << "AttachCompositorFrameSink failed (invalid window id)"; DVLOG(1) << "AttachCompositorFrameSink failed (invalid window id)";
return; return;
} }
ServerWindow* server_window = ServerWindow::GetMayBeNull(window); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window);
// If this isn't called on the root, then only allow it if there is not // If this isn't called on the root, then only allow it if there is not
// another client embedded in the window. // another client embedded in the window.
const bool allow = IsClientRootWindow(window) || const bool allow = IsClientRootWindow(window) ||
(IsClientCreatedWindow(window) && (IsClientCreatedWindow(window) &&
server_window->embedded_window_tree() == nullptr); proxy_window->embedded_window_tree() == nullptr);
if (!allow) { if (!allow) {
DVLOG(1) << "AttachCompositorFrameSink failed (policy disallowed)"; DVLOG(1) << "AttachCompositorFrameSink failed (policy disallowed)";
return; return;
} }
server_window->AttachCompositorFrameSink(std::move(compositor_frame_sink), proxy_window->AttachCompositorFrameSink(std::move(compositor_frame_sink),
std::move(client)); std::move(client));
} }
void WindowTree::AddWindow(uint32_t change_id, Id parent_id, Id child_id) { void WindowTree::AddWindow(uint32_t change_id, Id parent_id, Id child_id) {
@@ -1824,7 +1821,7 @@ void WindowTree::EmbedUsingToken(Id transport_window_id,
return; return;
} }
ServerWindow* server_window = ServerWindow::GetMayBeNull(window); ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window);
const bool owner_intercept_events = const bool owner_intercept_events =
(connection_type_ != ConnectionType::kEmbedding && (connection_type_ != ConnectionType::kEmbedding &&
(embed_flags & mojom::kEmbedFlagEmbedderInterceptsEvents) != 0); (embed_flags & mojom::kEmbedFlagEmbedderInterceptsEvents) != 0);
@@ -1833,12 +1830,12 @@ void WindowTree::EmbedUsingToken(Id transport_window_id,
std::unique_ptr<Embedding> embedding = std::unique_ptr<Embedding> embedding =
std::make_unique<Embedding>(this, window, owner_intercept_events); std::make_unique<Embedding>(this, window, owner_intercept_events);
embedding->InitForEmbedInExistingTree(tree_and_id.tree); embedding->InitForEmbedInExistingTree(tree_and_id.tree);
server_window->SetEmbedding(std::move(embedding)); proxy_window->SetEmbedding(std::move(embedding));
// Convert |transport_window_id| to ensure the client is supplied a consistent // Convert |transport_window_id| to ensure the client is supplied a consistent
// client-id. // client-id.
window_tree_client_->OnFrameSinkIdAllocated( window_tree_client_->OnFrameSinkIdAllocated(
ClientWindowIdToTransportId(MakeClientWindowId(transport_window_id)), ClientWindowIdToTransportId(MakeClientWindowId(transport_window_id)),
server_window->frame_sink_id()); proxy_window->frame_sink_id());
std::move(callback).Run(true); std::move(callback).Run(true);
} }

@@ -38,7 +38,7 @@ class ClientRoot;
class Embedding; class Embedding;
class EventObserverHelper; class EventObserverHelper;
class FocusHandler; class FocusHandler;
class ServerWindow; class ProxyWindow;
class TopmostWindowObserver; class TopmostWindowObserver;
class WindowManagerInterface; class WindowManagerInterface;
class WindowService; class WindowService;
@@ -107,7 +107,7 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowTree
bool IsTopLevel(aura::Window* window); bool IsTopLevel(aura::Window* window);
// Asks the client to close |window|. |window| must be a top-level window. // Asks the client to close |window|. |window| must be a top-level window.
void RequestClose(ServerWindow* window); void RequestClose(ProxyWindow* window);
// Called when an Embedding is destroyed. This is only called for Embeddings // Called when an Embedding is destroyed. This is only called for Embeddings
// that do not own the WindowTree (see Embedding for more details on when this // that do not own the WindowTree (see Embedding for more details on when this
@@ -220,7 +220,7 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowTree
bool IsWindowRootOfAnotherClient(aura::Window* window) const; bool IsWindowRootOfAnotherClient(aura::Window* window) const;
// Returns true if |window| has an ancestor that intercepts events. // Returns true if |window| has an ancestor that intercepts events.
bool DoesAnyAncestorInterceptEvents(ServerWindow* window); bool DoesAnyAncestorInterceptEvents(ProxyWindow* window);
// Called when one of the windows known to the client loses capture. // Called when one of the windows known to the client loses capture.
// |lost_capture| is the window that had capture. // |lost_capture| is the window that had capture.

@@ -4,7 +4,7 @@
#include "services/ws/window_tree_test_helper.h" #include "services/ws/window_tree_test_helper.h"
#include "services/ws/server_window.h" #include "services/ws/proxy_window.h"
#include "services/ws/window_tree_binding.h" #include "services/ws/window_tree_binding.h"
namespace ws { namespace ws {
@@ -123,7 +123,7 @@ Embedding* WindowTreeTestHelper::Embed(aura::Window* window,
std::move(client_ptr), client, embed_flags)) { std::move(client_ptr), client, embed_flags)) {
return nullptr; return nullptr;
} }
return ServerWindow::GetMayBeNull(window)->embedding(); return ProxyWindow::GetMayBeNull(window)->embedding();
} }
void WindowTreeTestHelper::SetEventTargetingPolicy( void WindowTreeTestHelper::SetEventTargetingPolicy(

@@ -90,7 +90,7 @@ class WindowTreeTestHelper {
uint32_t change_id = 1); uint32_t change_id = 1);
// Creates a new embedding. On success the new Embedding is returned. The // Creates a new embedding. On success the new Embedding is returned. The
// returned Embedding is owned by the ServerWindow for |window|. // returned Embedding is owned by the ProxyWindow for |window|.
Embedding* Embed(aura::Window* window, Embedding* Embed(aura::Window* window,
mojom::WindowTreeClientPtr client_ptr, mojom::WindowTreeClientPtr client_ptr,
mojom::WindowTreeClient* client, mojom::WindowTreeClient* client,

@@ -15,10 +15,10 @@
#include "components/viz/host/host_frame_sink_manager.h" #include "components/viz/host/host_frame_sink_manager.h"
#include "components/viz/test/fake_host_frame_sink_client.h" #include "components/viz/test/fake_host_frame_sink_client.h"
#include "services/ws/event_test_utils.h" #include "services/ws/event_test_utils.h"
#include "services/ws/proxy_window.h"
#include "services/ws/proxy_window_test_helper.h"
#include "services/ws/public/cpp/property_type_converters.h" #include "services/ws/public/cpp/property_type_converters.h"
#include "services/ws/public/mojom/window_manager.mojom.h" #include "services/ws/public/mojom/window_manager.mojom.h"
#include "services/ws/server_window.h"
#include "services/ws/server_window_test_helper.h"
#include "services/ws/window_delegate_impl.h" #include "services/ws/window_delegate_impl.h"
#include "services/ws/window_service.h" #include "services/ws/window_service.h"
#include "services/ws/window_service_test_setup.h" #include "services/ws/window_service_test_setup.h"
@@ -1218,17 +1218,16 @@ TEST(WindowTreeTest, PointerDownResetOnCaptureChange) {
ui::test::EventGenerator event_generator(setup.root()); ui::test::EventGenerator event_generator(setup.root());
event_generator.MoveMouseTo(5, 5); event_generator.MoveMouseTo(5, 5);
event_generator.PressLeftButton(); event_generator.PressLeftButton();
ServerWindow* top_level_server_window = ServerWindow::GetMayBeNull(top_level); ProxyWindow* top_level_proxy_window = ProxyWindow::GetMayBeNull(top_level);
ASSERT_TRUE(top_level_server_window); ASSERT_TRUE(top_level_proxy_window);
ServerWindowTestHelper top_level_server_window_helper( ProxyWindowTestHelper top_level_proxy_window_helper(top_level_proxy_window);
top_level_server_window); EXPECT_TRUE(top_level_proxy_window_helper.IsHandlingPointerPress(
EXPECT_TRUE(top_level_server_window_helper.IsHandlingPointerPress(
ui::MouseEvent::kMousePointerId)); ui::MouseEvent::kMousePointerId));
// Set capture on |window|, top_level should no longer be in pointer-down // Set capture on |window|, top_level should no longer be in pointer-down
// (because capture changed). // (because capture changed).
EXPECT_TRUE(setup.window_tree_test_helper()->SetCapture(window)); EXPECT_TRUE(setup.window_tree_test_helper()->SetCapture(window));
EXPECT_FALSE(top_level_server_window_helper.IsHandlingPointerPress( EXPECT_FALSE(top_level_proxy_window_helper.IsHandlingPointerPress(
ui::MouseEvent::kMousePointerId)); ui::MouseEvent::kMousePointerId));
} }
@@ -1245,16 +1244,15 @@ TEST(WindowTreeTest, PointerDownResetOnHide) {
ui::test::EventGenerator event_generator(setup.root()); ui::test::EventGenerator event_generator(setup.root());
event_generator.MoveMouseTo(5, 5); event_generator.MoveMouseTo(5, 5);
event_generator.PressLeftButton(); event_generator.PressLeftButton();
ServerWindow* top_level_server_window = ServerWindow::GetMayBeNull(top_level); ProxyWindow* top_level_proxy_window = ProxyWindow::GetMayBeNull(top_level);
ASSERT_TRUE(top_level_server_window); ASSERT_TRUE(top_level_proxy_window);
ServerWindowTestHelper top_level_server_window_helper( ProxyWindowTestHelper top_level_proxy_window_helper(top_level_proxy_window);
top_level_server_window); EXPECT_TRUE(top_level_proxy_window_helper.IsHandlingPointerPress(
EXPECT_TRUE(top_level_server_window_helper.IsHandlingPointerPress(
ui::MouseEvent::kMousePointerId)); ui::MouseEvent::kMousePointerId));
// Hiding should implicitly cancel capture. // Hiding should implicitly cancel capture.
top_level->Hide(); top_level->Hide();
EXPECT_FALSE(top_level_server_window_helper.IsHandlingPointerPress( EXPECT_FALSE(top_level_proxy_window_helper.IsHandlingPointerPress(
ui::MouseEvent::kMousePointerId)); ui::MouseEvent::kMousePointerId));
} }
@@ -1342,7 +1340,7 @@ TEST(WindowTreeTest, Embed) {
const Id embed_window_transport_id = const Id embed_window_transport_id =
setup.window_tree_test_helper()->TransportIdForWindow(embed_window); setup.window_tree_test_helper()->TransportIdForWindow(embed_window);
EXPECT_EQ(embed_window_transport_id, (*setup.changes())[0].window_id); EXPECT_EQ(embed_window_transport_id, (*setup.changes())[0].window_id);
EXPECT_EQ(ServerWindow::GetMayBeNull(embed_window)->frame_sink_id(), EXPECT_EQ(ProxyWindow::GetMayBeNull(embed_window)->frame_sink_id(),
(*setup.changes())[0].frame_sink_id); (*setup.changes())[0].frame_sink_id);
} }
@@ -1543,10 +1541,10 @@ TEST(WindowTreeTest, DeleteEmbededTreeFromScheduleEmbedForExistingClient) {
&embed_result)); &embed_result));
EXPECT_TRUE(embed_callback_called); EXPECT_TRUE(embed_callback_called);
EXPECT_TRUE(embed_result); EXPECT_TRUE(embed_result);
EXPECT_TRUE(ServerWindow::GetMayBeNull(window_in_parent)->HasEmbedding()); EXPECT_TRUE(ProxyWindow::GetMayBeNull(window_in_parent)->HasEmbedding());
tree2.reset(); tree2.reset();
EXPECT_FALSE(ServerWindow::GetMayBeNull(window_in_parent)->HasEmbedding()); EXPECT_FALSE(ProxyWindow::GetMayBeNull(window_in_parent)->HasEmbedding());
} }
TEST(WindowTreeTest, StackAtTop) { TEST(WindowTreeTest, StackAtTop) {
@@ -2044,15 +2042,15 @@ TEST(WindowTreeTest, DsfChanges) {
setup.window_tree_test_helper()->NewTopLevelWindow(); setup.window_tree_test_helper()->NewTopLevelWindow();
ASSERT_TRUE(top_level); ASSERT_TRUE(top_level);
top_level->Show(); top_level->Show();
ServerWindow* top_level_server_window = ServerWindow::GetMayBeNull(top_level); ProxyWindow* top_level_proxy_window = ProxyWindow::GetMayBeNull(top_level);
const base::Optional<viz::LocalSurfaceId> initial_surface_id = const base::Optional<viz::LocalSurfaceId> initial_surface_id =
top_level_server_window->local_surface_id(); top_level_proxy_window->local_surface_id();
EXPECT_TRUE(initial_surface_id); EXPECT_TRUE(initial_surface_id);
// Changing the scale factor should change the LocalSurfaceId. // Changing the scale factor should change the LocalSurfaceId.
setup.aura_test_helper()->test_screen()->SetDeviceScaleFactor(2.0f); setup.aura_test_helper()->test_screen()->SetDeviceScaleFactor(2.0f);
EXPECT_TRUE(top_level_server_window->local_surface_id()); EXPECT_TRUE(top_level_proxy_window->local_surface_id());
EXPECT_NE(*top_level_server_window->local_surface_id(), *initial_surface_id); EXPECT_NE(*top_level_proxy_window->local_surface_id(), *initial_surface_id);
} }
TEST(WindowTreeTest, DontSendGestures) { TEST(WindowTreeTest, DontSendGestures) {
@@ -2142,16 +2140,16 @@ TEST(WindowTreeTest, AttachFrameSinkId) {
test_frame_sink_id, &test_host_frame_sink_client, test_frame_sink_id, &test_host_frame_sink_client,
viz::ReportFirstSurfaceActivation::kYes); viz::ReportFirstSurfaceActivation::kYes);
EXPECT_EQ(test_frame_sink_id, EXPECT_EQ(test_frame_sink_id,
ServerWindow::GetMayBeNull(child_window)->attached_frame_sink_id()); ProxyWindow::GetMayBeNull(child_window)->attached_frame_sink_id());
top_level->AddChild(child_window); top_level->AddChild(child_window);
EXPECT_TRUE(host_frame_sink_manager->IsFrameSinkHierarchyRegistered( EXPECT_TRUE(host_frame_sink_manager->IsFrameSinkHierarchyRegistered(
ServerWindow::GetMayBeNull(top_level)->frame_sink_id(), ProxyWindow::GetMayBeNull(top_level)->frame_sink_id(),
test_frame_sink_id)); test_frame_sink_id));
// Removing the window should remove the association. // Removing the window should remove the association.
top_level->RemoveChild(child_window); top_level->RemoveChild(child_window);
EXPECT_FALSE(host_frame_sink_manager->IsFrameSinkHierarchyRegistered( EXPECT_FALSE(host_frame_sink_manager->IsFrameSinkHierarchyRegistered(
ServerWindow::GetMayBeNull(top_level)->frame_sink_id(), ProxyWindow::GetMayBeNull(top_level)->frame_sink_id(),
test_frame_sink_id)); test_frame_sink_id));
setup.window_tree_test_helper()->DeleteWindow(child_window); setup.window_tree_test_helper()->DeleteWindow(child_window);