diff --git a/ash/accelerators/debug_commands.cc b/ash/accelerators/debug_commands.cc index 098d507690764..70e61dc824ea0 100644 --- a/ash/accelerators/debug_commands.cc +++ b/ash/accelerators/debug_commands.cc @@ -88,7 +88,7 @@ void PrintWindowHierarchy(ws::WindowService* window_service, const gfx::Vector2dF& subpixel_position_offset = window->layer()->subpixel_position_offset(); *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 << name << " (" << window << ")" << " type=" << window->type(); diff --git a/ash/host/ash_window_tree_host_platform.cc b/ash/host/ash_window_tree_host_platform.cc index d7a8a368d4c86..7f237a719c84e 100644 --- a/ash/host/ash_window_tree_host_platform.cc +++ b/ash/host/ash_window_tree_host_platform.cc @@ -223,7 +223,7 @@ bool AshWindowTreeHostPlatform::ShouldSendKeyEventToIme() { // 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). aura::Window* target = window()->targeter()->FindTargetForKeyEvent(window()); - return !target || !ws::WindowService::HasRemoteClient(target); + return !target || !ws::WindowService::IsProxyWindow(target); } void AshWindowTreeHostPlatform::SetTextInputState( diff --git a/ash/ime/ime_focus_handler.cc b/ash/ime/ime_focus_handler.cc index 6fa099894af3c..90ac32bd738fe 100644 --- a/ash/ime/ime_focus_handler.cc +++ b/ash/ime/ime_focus_handler.cc @@ -25,17 +25,17 @@ ImeFocusHandler::~ImeFocusHandler() { void ImeFocusHandler::OnWindowFocused(aura::Window* gained_focus, aura::Window* lost_focus) { - const bool client_window_gaining_focus = - ws::WindowService::HasRemoteClient(gained_focus); - const bool client_window_losing_focus = - ws::WindowService::HasRemoteClient(lost_focus); + const bool proxy_window_gaining_focus = + ws::WindowService::IsProxyWindow(gained_focus); + const bool proxy_window_losing_focus = + ws::WindowService::IsProxyWindow(lost_focus); - // Focus moves to a ClientWindow from an ash window. - if (client_window_gaining_focus && !client_window_losing_focus) + // Focus moves to a ProxyWindow from an ash window. + if (proxy_window_gaining_focus && !proxy_window_losing_focus) input_method_->OnBlur(); - // Focus moves to an ash window from a ClientWindow. - if (!client_window_gaining_focus && client_window_losing_focus) + // Focus moves to an ash window from a ProxyWindow. + if (!proxy_window_gaining_focus && proxy_window_losing_focus) input_method_->OnFocus(); } diff --git a/ash/laser/laser_pointer_controller_unittest.cc b/ash/laser/laser_pointer_controller_unittest.cc index 0c991088cbd9f..0661648130fb7 100644 --- a/ash/laser/laser_pointer_controller_unittest.cc +++ b/ash/laser/laser_pointer_controller_unittest.cc @@ -8,7 +8,7 @@ #include "ash/laser/laser_pointer_view.h" #include "ash/shell.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" namespace ash { @@ -158,11 +158,10 @@ TEST_F(LaserPointerControllerTest, LaserPointerPrediction) { TEST_F(LaserPointerControllerTest, LaserPointerWorksWithRemoteApp) { std::unique_ptr<aura::Window> window = CreateTestWindow(gfx::Rect(50, 50, 100, 100)); - ws::ServerWindow* server_window = - ws::ServerWindow::GetMayBeNull(window.get()); - ASSERT_TRUE(server_window); + ws::ProxyWindow* proxy_window = ws::ProxyWindow::GetMayBeNull(window.get()); + ASSERT_TRUE(proxy_window); // 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. ui::test::EventGenerator* event_generator = GetEventGenerator(); diff --git a/ash/shell.cc b/ash/shell.cc index 8535b8f87af4d..9b62ecedc4b80 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -384,8 +384,8 @@ bool Shell::IsSystemModalWindowOpen() { } // static -bool Shell::HasRemoteClient(aura::Window* window) { - return ws::WindowService::HasRemoteClient(window); +bool Shell::IsProxyWindow(aura::Window* window) { + return ws::WindowService::IsProxyWindow(window); } // static diff --git a/ash/shell.h b/ash/shell.h index 3341f9cc8b0b9..e02811f585f7a 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -267,9 +267,10 @@ class ASH_EXPORT Shell : public SessionObserver, // Returns true if a system-modal dialog window is currently open. static bool IsSystemModalWindowOpen(); - // Whether |window| hosts a remote client (e.g. the keyboard shortcut viewer - // app under classic ash, or a browser window under mash). - static bool HasRemoteClient(aura::Window* window); + // Returns true if |window| is a proxy window. A proxy window is a window that + // was created by way of a WindowService client (e.g. the keyboard shortcut + // 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|. static void RegisterLocalStatePrefs(PrefRegistrySimple* registry, diff --git a/ash/utility/screenshot_controller.cc b/ash/utility/screenshot_controller.cc index 5c45c625789de..1d65e73784657 100644 --- a/ash/utility/screenshot_controller.cc +++ b/ash/utility/screenshot_controller.cc @@ -73,7 +73,7 @@ bool IsTopLevelWindow(aura::Window* window) { !window->delegate()) { return false; } - if (ws::WindowService::HasRemoteClient(window)) + if (ws::WindowService::IsProxyWindow(window)) return ws::WindowService::IsTopLevelWindow(window); return true; } diff --git a/ash/wm/window_finder.cc b/ash/wm/window_finder.cc index 1738dfc79c916..45d7f20718bda 100644 --- a/ash/wm/window_finder.cc +++ b/ash/wm/window_finder.cc @@ -23,7 +23,7 @@ bool IsTopLevelWindow(aura::Window* window) { // ui::LAYER_TEXTURED is for non-mash environment. For Mash, browser windows // are not with LAYER_TEXTURED but have a remote client. 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|. diff --git a/ash/ws/window_lookup.cc b/ash/ws/window_lookup.cc index aaa1d48ba8ff5..53b81b4fd02bb 100644 --- a/ash/ws/window_lookup.cc +++ b/ash/ws/window_lookup.cc @@ -28,7 +28,7 @@ ws::Id GetTransportId(aura::Window* window) { } // namespace bool IsProxyWindow(aura::Window* window) { - return ws::WindowService::HasRemoteClient(window); + return ws::WindowService::IsProxyWindow(window); } aura::Window* GetProxyWindowForClientWindow(aura::Window* window) { diff --git a/services/ws/BUILD.gn b/services/ws/BUILD.gn index 459f359c82132..e37828e19ac71 100644 --- a/services/ws/BUILD.gn +++ b/services/ws/BUILD.gn @@ -52,12 +52,12 @@ component("lib") { "host_event_queue.cc", "injected_event_handler.cc", "injected_event_handler.h", + "proxy_window.cc", + "proxy_window.h", "remoting_event_injector.cc", "remoting_event_injector.h", "screen_provider.cc", "screen_provider.h", - "server_window.cc", - "server_window.h", "topmost_window_observer.cc", "topmost_window_observer.h", "user_activity_monitor.cc", @@ -133,8 +133,8 @@ static_library("test_support") { "event_queue_test_helper.h", "event_test_utils.cc", "event_test_utils.h", - "server_window_test_helper.cc", - "server_window_test_helper.h", + "proxy_window_test_helper.cc", + "proxy_window_test_helper.h", "test_change_tracker.cc", "test_change_tracker.h", "test_host_event_dispatcher.cc", @@ -213,8 +213,8 @@ source_set("tests") { "event_queue_unittest.cc", "focus_handler_unittest.cc", "injected_event_handler_unittest.cc", + "proxy_window_unittest.cc", "screen_provider_unittest.cc", - "server_window_unittest.cc", "topmost_window_observer_unittest.cc", "user_activity_monitor_unittest.cc", "window_delegate_impl_unittest.cc", diff --git a/services/ws/client_root.cc b/services/ws/client_root.cc index f91b55dbb426c..b5612f4d4d62e 100644 --- a/services/ws/client_root.cc +++ b/services/ws/client_root.cc @@ -10,7 +10,7 @@ #include "components/viz/host/host_frame_sink_manager.h" #include "services/ws/client_change.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_tree.h" #include "ui/aura/client/screen_position_client.h" @@ -47,15 +47,14 @@ ClientRoot::ClientRoot(WindowTree* window_tree, } ClientRoot::~ClientRoot() { - ServerWindow* server_window = ServerWindow::GetMayBeNull(window_); + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window_); window_->RemoveObserver(this); if (window_->GetHost()) window_->GetHost()->RemoveObserver(this); viz::HostFrameSinkManager* host_frame_sink_manager = window_->env()->context_factory_private()->GetHostFrameSinkManager(); - host_frame_sink_manager->InvalidateFrameSinkId( - server_window->frame_sink_id()); + host_frame_sink_manager->InvalidateFrameSinkId(proxy_window->frame_sink_id()); } void ClientRoot::SetClientAreaInsets(const gfx::Insets& client_area_insets) { @@ -70,7 +69,7 @@ void ClientRoot::RegisterVizEmbeddingSupport() { viz::HostFrameSinkManager* host_frame_sink_manager = window_->env()->context_factory_private()->GetHostFrameSinkManager(); viz::FrameSinkId frame_sink_id = - ServerWindow::GetMayBeNull(window_)->frame_sink_id(); + ProxyWindow::GetMayBeNull(window_)->frame_sink_id(); host_frame_sink_manager->RegisterFrameSinkId( frame_sink_id, this, viz::ReportFirstSurfaceActivation::kYes); window_->SetEmbedFrameSinkId(frame_sink_id); @@ -83,8 +82,8 @@ bool ClientRoot::ShouldAssignLocalSurfaceId() { // WindowService. First level embeddings have no embeddings above them. if (is_top_level_) return true; - ServerWindow* server_window = ServerWindow::GetMayBeNull(window_); - return server_window->owning_window_tree() == nullptr; + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window_); + return proxy_window->owning_window_tree() == nullptr; } void ClientRoot::UpdateLocalSurfaceIdIfNecessary() { @@ -93,14 +92,14 @@ void ClientRoot::UpdateLocalSurfaceIdIfNecessary() { gfx::Size size_in_pixels = 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 // LocalSurfaceId is used. 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()) { parent_local_surface_id_allocator_.GenerateId(); - server_window->set_local_surface_id( + proxy_window->set_local_surface_id( parent_local_surface_id_allocator_.GetCurrentLocalSurfaceIdAllocation() .local_surface_id()); last_surface_size_in_pixels_ = size_in_pixels; @@ -116,28 +115,28 @@ void ClientRoot::OnLocalSurfaceIdChanged() { : window_->bounds()); } -void ClientRoot::AttachChildFrameSinkId(ServerWindow* server_window) { - DCHECK(server_window->attached_frame_sink_id().is_valid()); - DCHECK(ServerWindow::GetMayBeNull(window_)->frame_sink_id().is_valid()); +void ClientRoot::AttachChildFrameSinkId(ProxyWindow* proxy_window) { + DCHECK(proxy_window->attached_frame_sink_id().is_valid()); + DCHECK(ProxyWindow::GetMayBeNull(window_)->frame_sink_id().is_valid()); viz::HostFrameSinkManager* host_frame_sink_manager = window_->env()->context_factory_private()->GetHostFrameSinkManager(); 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)) { 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) { - DCHECK(server_window->attached_frame_sink_id().is_valid()); - DCHECK(ServerWindow::GetMayBeNull(window_)->frame_sink_id().is_valid()); +void ClientRoot::UnattachChildFrameSinkId(ProxyWindow* proxy_window) { + DCHECK(proxy_window->attached_frame_sink_id().is_valid()); + DCHECK(ProxyWindow::GetMayBeNull(window_)->frame_sink_id().is_valid()); viz::HostFrameSinkManager* host_frame_sink_manager = window_->env()->context_factory_private()->GetHostFrameSinkManager(); 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 = - server_window->attached_frame_sink_id(); + proxy_window->attached_frame_sink_id(); if (host_frame_sink_manager->IsFrameSinkHierarchyRegistered( root_frame_sink_id, window_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) { - if (server_window->attached_frame_sink_id().is_valid()) - AttachChildFrameSinkId(server_window); +void ClientRoot::AttachChildFrameSinkIdRecursive(ProxyWindow* proxy_window) { + if (proxy_window->attached_frame_sink_id().is_valid()) + AttachChildFrameSinkId(proxy_window); - for (aura::Window* child : server_window->window()->children()) { - ServerWindow* child_server_window = ServerWindow::GetMayBeNull(child); - if (child_server_window->owning_window_tree() == window_tree_) - AttachChildFrameSinkIdRecursive(child_server_window); + for (aura::Window* child : proxy_window->window()->children()) { + ProxyWindow* child_proxy_window = ProxyWindow::GetMayBeNull(child); + if (child_proxy_window->owning_window_tree() == window_tree_) + AttachChildFrameSinkIdRecursive(child_proxy_window); } } -void ClientRoot::UnattachChildFrameSinkIdRecursive( - ServerWindow* server_window) { - if (server_window->attached_frame_sink_id().is_valid()) - UnattachChildFrameSinkId(server_window); +void ClientRoot::UnattachChildFrameSinkIdRecursive(ProxyWindow* proxy_window) { + if (proxy_window->attached_frame_sink_id().is_valid()) + UnattachChildFrameSinkId(proxy_window); - for (aura::Window* child : server_window->window()->children()) { - ServerWindow* child_server_window = ServerWindow::GetMayBeNull(child); - if (child_server_window->owning_window_tree() == window_tree_) - UnattachChildFrameSinkIdRecursive(child_server_window); + for (aura::Window* child : proxy_window->window()->children()) { + ProxyWindow* child_proxy_window = ProxyWindow::GetMayBeNull(child); + if (child_proxy_window->owning_window_tree() == window_tree_) + UnattachChildFrameSinkIdRecursive(child_proxy_window); } } void ClientRoot::UpdatePrimarySurfaceId() { UpdateLocalSurfaceIdIfNecessary(); - ServerWindow* server_window = ServerWindow::GetMayBeNull(window_); - if (server_window->local_surface_id().has_value()) { + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window_); + if (proxy_window->local_surface_id().has_value()) { client_surface_embedder_->SetSurfaceId(viz::SurfaceId( - window_->GetFrameSinkId(), *server_window->local_surface_id())); + window_->GetFrameSinkId(), *proxy_window->local_surface_id())); if (fallback_surface_info_) { client_surface_embedder_->SetFallbackSurfaceInfo(*fallback_surface_info_); fallback_surface_info_.reset(); @@ -203,7 +201,7 @@ void ClientRoot::NotifyClientOfNewBounds(const gfx::Rect& old_bounds) { last_bounds_ = window_->GetBoundsInScreen(); window_tree_->window_tree_client_->OnWindowBoundsChanged( window_tree_->TransportIdForWindow(window_), old_bounds, last_bounds_, - ServerWindow::GetMayBeNull(window_)->local_surface_id()); + ProxyWindow::GetMayBeNull(window_)->local_surface_id()); } void ClientRoot::OnPositionInRootChanged() { @@ -303,8 +301,8 @@ void ClientRoot::OnHostResized(aura::WindowTreeHost* host) { void ClientRoot::OnFirstSurfaceActivation( const viz::SurfaceInfo& surface_info) { - ServerWindow* server_window = ServerWindow::GetMayBeNull(window_); - if (server_window->local_surface_id().has_value()) { + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window_); + if (proxy_window->local_surface_id().has_value()) { DCHECK(!fallback_surface_info_); if (!client_surface_embedder_->HasPrimarySurfaceId()) UpdatePrimarySurfaceId(); @@ -315,7 +313,7 @@ void ClientRoot::OnFirstSurfaceActivation( if (!window_tree_->client_name().empty()) { // OnFirstSurfaceActivation() should only be called after // AttachCompositorFrameSink(). - DCHECK(server_window->attached_compositor_frame_sink()); + DCHECK(proxy_window->attached_compositor_frame_sink()); window_tree_->window_service()->OnFirstSurfaceActivation( window_tree_->client_name()); } diff --git a/services/ws/client_root.h b/services/ws/client_root.h index 091f95601705b..d96b872b24c27 100644 --- a/services/ws/client_root.h +++ b/services/ws/client_root.h @@ -37,7 +37,7 @@ class SurfaceInfo; namespace ws { -class ServerWindow; +class ProxyWindow; class WindowTree; // 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. void OnLocalSurfaceIdChanged(); - // Attaches/unattaches server_window->attached_frame_sink_id() to the + // Attaches/unattaches proxy_window->attached_frame_sink_id() to the // HostFrameSinkManager. - void AttachChildFrameSinkId(ServerWindow* server_window); - void UnattachChildFrameSinkId(ServerWindow* server_window); + void AttachChildFrameSinkId(ProxyWindow* proxy_window); + void UnattachChildFrameSinkId(ProxyWindow* proxy_window); // Recurses through all descendants with the same WindowTree calling // AttachChildFrameSinkId()/UnattachChildFrameSinkId(). - void AttachChildFrameSinkIdRecursive(ServerWindow* server_window); - void UnattachChildFrameSinkIdRecursive(ServerWindow* server_window); + void AttachChildFrameSinkIdRecursive(ProxyWindow* proxy_window); + void UnattachChildFrameSinkIdRecursive(ProxyWindow* proxy_window); private: friend class ClientRootTestHelper; diff --git a/services/ws/client_root_test_helper.h b/services/ws/client_root_test_helper.h index 7674df3b28bba..c09abdf07c9a0 100644 --- a/services/ws/client_root_test_helper.h +++ b/services/ws/client_root_test_helper.h @@ -16,7 +16,7 @@ namespace ws { class ClientRoot; -// Used for accessing private members of ServerWindow in tests. +// Used for accessing private members of ClientRoot in tests. class ClientRootTestHelper { public: explicit ClientRootTestHelper(ClientRoot* client_root); diff --git a/services/ws/event_queue.cc b/services/ws/event_queue.cc index f379fa7a202ba..2dd345a2bd8d2 100644 --- a/services/ws/event_queue.cc +++ b/services/ws/event_queue.cc @@ -79,7 +79,7 @@ bool EventQueue::ShouldQueueEvent(HostEventQueue* host_queue, DCHECK(targeter); aura::Window* target = targeter->FindTargetForKeyEvent(host_queue->window_tree_host()->window()); - return target && WindowService::HasRemoteClient(target); + return target && WindowService::IsProxyWindow(target); } void EventQueue::NotifyWhenReadyToDispatch(base::OnceClosure closure) { diff --git a/services/ws/focus_handler.cc b/services/ws/focus_handler.cc index 06ad220c4eec4..ad9ad5dbadb95 100644 --- a/services/ws/focus_handler.cc +++ b/services/ws/focus_handler.cc @@ -6,7 +6,7 @@ #include "services/ws/client_change.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_service.h" #include "services/ws/window_service_delegate.h" @@ -43,17 +43,17 @@ bool FocusHandler::SetFocus(aura::Window* window) { aura::client::FocusClient* 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 (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 - // (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. - if (server_window->focus_owner()) { - server_window->focus_owner()->window_tree_client_->OnWindowFocused( + if (proxy_window->focus_owner()) { + proxy_window->focus_owner()->window_tree_client_->OnWindowFocused( kInvalidTransportId); } - server_window->set_focus_owner(window_tree_); + proxy_window->set_focus_owner(window_tree_); } return true; } @@ -75,8 +75,8 @@ bool FocusHandler::SetFocus(aura::Window* window) { << " failed for " << window->GetName() << ")"; return false; } - if (server_window) - server_window->set_focus_owner(window_tree_); + if (proxy_window) + proxy_window->set_focus_owner(window_tree_); return true; } } @@ -88,8 +88,8 @@ bool FocusHandler::SetFocus(aura::Window* window) { return false; } - if (server_window) - server_window->set_focus_owner(window_tree_); + if (proxy_window) + proxy_window->set_focus_owner(window_tree_); return true; } @@ -113,12 +113,12 @@ bool FocusHandler::IsFocusableWindow(aura::Window* window) const { window_tree_->IsClientRootWindow(window)); } -bool FocusHandler::IsEmbeddedClient(ServerWindow* server_window) const { - return server_window->embedded_window_tree() == window_tree_; +bool FocusHandler::IsEmbeddedClient(ProxyWindow* proxy_window) const { + return proxy_window->embedded_window_tree() == window_tree_; } -bool FocusHandler::IsOwningClient(ServerWindow* server_window) const { - return server_window->owning_window_tree() == window_tree_; +bool FocusHandler::IsOwningClient(ProxyWindow* proxy_window) const { + return proxy_window->owning_window_tree() == window_tree_; } 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. bool notified_gained = false; if (gained_focus) { - ServerWindow* server_window = ServerWindow::GetMayBeNull(gained_focus); - if (server_window && (IsEmbeddedClient(server_window) || - (!server_window->embedded_window_tree() && - IsOwningClient(server_window)))) { - server_window->set_focus_owner(window_tree_); + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(gained_focus); + if (proxy_window && (IsEmbeddedClient(proxy_window) || + (!proxy_window->embedded_window_tree() && + IsOwningClient(proxy_window)))) { + proxy_window->set_focus_owner(window_tree_); window_tree_->window_tree_client_->OnWindowFocused( window_tree_->TransportIdForWindow(gained_focus)); notified_gained = true; @@ -149,9 +149,9 @@ void FocusHandler::OnWindowFocused(aura::Window* gained_focus, } if (lost_focus && !notified_gained) { - ServerWindow* server_window = ServerWindow::GetMayBeNull(lost_focus); - if (server_window && server_window->focus_owner() == window_tree_) { - server_window->set_focus_owner(nullptr); + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(lost_focus); + if (proxy_window && proxy_window->focus_owner() == window_tree_) { + proxy_window->set_focus_owner(nullptr); window_tree_->window_tree_client_->OnWindowFocused(kInvalidTransportId); } } diff --git a/services/ws/focus_handler.h b/services/ws/focus_handler.h index c29ab40a83349..f53a92ff42528 100644 --- a/services/ws/focus_handler.h +++ b/services/ws/focus_handler.h @@ -14,7 +14,7 @@ class Window; namespace ws { -class ServerWindow; +class ProxyWindow; class WindowTree; // 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. bool IsFocusableWindow(aura::Window* window) const; - bool IsEmbeddedClient(ServerWindow* server_window) const; - bool IsOwningClient(ServerWindow* server_window) const; + bool IsEmbeddedClient(ProxyWindow* proxy_window) const; + bool IsOwningClient(ProxyWindow* proxy_window) const; // aura::client::FocusChangeObserver: void OnWindowFocused(aura::Window* gained_focus, diff --git a/services/ws/server_window.cc b/services/ws/proxy_window.cc similarity index 78% rename from services/ws/server_window.cc rename to services/ws/proxy_window.cc index 1b6d74d85af75..5d83311845735 100644 --- a/services/ws/server_window.cc +++ b/services/ws/proxy_window.cc @@ -2,7 +2,7 @@ // 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.h" +#include "services/ws/proxy_window.h" #include <utility> @@ -24,19 +24,19 @@ #include "ui/wm/core/capture_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 { -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 // of the window). A return value of false means the location is in the client // area. bool IsLocationInNonClientArea(const aura::Window* window, const gfx::Point& location) { - const ServerWindow* server_window = ServerWindow::GetMayBeNull(window); - if (!server_window || !server_window->IsTopLevel()) + const ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window); + if (!proxy_window || !proxy_window->IsTopLevel()) return false; // 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()); - client_area.Inset(server_window->client_area()); + client_area.Inset(proxy_window->client_area()); if (client_area.Contains(location)) return false; - for (const auto& rect : server_window->additional_client_areas()) { + for (const auto& rect : proxy_window->additional_client_areas()) { if (rect.Contains(location)) return false; } @@ -95,16 +95,16 @@ ui::PointerId GetPointerId(const ui::Event& event) { 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 // considered. This is done to ensure the delegate of the window (which is // local) sees the event. // . To ensure |WindowTree::intercepts_events_| is honored. -class ServerWindowTargeter : public aura::WindowTargeter { +class ProxyWindowTargeter : public aura::WindowTargeter { public: - explicit ServerWindowTargeter(ServerWindow* server_window) - : server_window_(server_window) {} - ~ServerWindowTargeter() override = default; + explicit ProxyWindowTargeter(ProxyWindow* proxy_window) + : proxy_window_(proxy_window) {} + ~ProxyWindowTargeter() override = default; // aura::WindowTargeter: bool SubtreeShouldBeExploredForEvent(aura::Window* window, @@ -113,7 +113,7 @@ class ServerWindowTargeter : public aura::WindowTargeter { // parent's WindowTargeter. This is necessary for targeters such as // EasyResizeWindowTargeter to work correctly. if (mouse_extend().IsEmpty() && touch_extend().IsEmpty() && - server_window_->IsTopLevel() && window->parent()) { + proxy_window_->IsTopLevel() && window->parent()) { aura::WindowTargeter* parent_targeter = static_cast<WindowTargeter*>(window->parent()->targeter()); if (parent_targeter) @@ -125,8 +125,8 @@ class ServerWindowTargeter : public aura::WindowTargeter { ui::EventTarget* FindTargetForEvent(ui::EventTarget* event_target, ui::Event* event) override { aura::Window* window = static_cast<aura::Window*>(event_target); - DCHECK_EQ(window, server_window_->window()); - if (server_window_->DoesOwnerInterceptEvents()) { + DCHECK_EQ(window, proxy_window_->window()); + if (proxy_window_->DoesOwnerInterceptEvents()) { // If the owner intercepts events, then don't recurse (otherwise events // would go to a descendant). return event_target->CanAcceptEvent(*event) ? window : nullptr; @@ -143,28 +143,28 @@ class ServerWindowTargeter : public aura::WindowTargeter { } 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. -// ServerWindowEventHandler adds itself to the pre-phase to ensure it's +// ProxyWindowEventHandler is used to forward events to the client. +// ProxyWindowEventHandler adds itself to the pre-phase to ensure it's // considered before the Window's delegate (or other EventHandlers). -class ServerWindowEventHandler : public ui::EventHandler { +class ProxyWindowEventHandler : public ui::EventHandler { public: - explicit ServerWindowEventHandler(ServerWindow* server_window) - : server_window_(server_window) { + explicit ProxyWindowEventHandler(ProxyWindow* proxy_window) + : proxy_window_(proxy_window) { // Use |kDefault| so as not to conflict with other important pre-target // handlers (such as laser pointer). window()->AddPreTargetHandler(this, ui::EventTarget::Priority::kDefault); } - ~ServerWindowEventHandler() override { + ~ProxyWindowEventHandler() override { window()->RemovePreTargetHandler(this); } - ServerWindow* server_window() { return server_window_; } - aura::Window* window() { return server_window_->window(); } + ProxyWindow* proxy_window() { return proxy_window_; } + aura::Window* window() { return proxy_window_->window(); } // ui::EventHandler: void OnEvent(ui::Event* event) override { @@ -178,19 +178,19 @@ class ServerWindowEventHandler : public ui::EventHandler { if (HandleInterceptedEvent(event) || ShouldIgnoreEvent(*event)) return; - auto* owning = server_window_->owning_window_tree(); - auto* embedded = server_window_->embedded_window_tree(); + auto* owning = proxy_window_->owning_window_tree(); + auto* embedded = proxy_window_->embedded_window_tree(); WindowTree* target_client = nullptr; - if (server_window_->DoesOwnerInterceptEvents()) { + if (proxy_window_->DoesOwnerInterceptEvents()) { // A client that intercepts events, always gets the event regardless of // focus/capture. target_client = owning; } else if (event->IsKeyEvent()) { - if (!server_window_->focus_owner()) + if (!proxy_window_->focus_owner()) return; // The local environment is going to process the event. - target_client = server_window_->focus_owner(); - } else if (server_window()->capture_owner()) { - target_client = server_window()->capture_owner(); + target_client = proxy_window_->focus_owner(); + } else if (proxy_window()->capture_owner()) { + target_client = proxy_window()->capture_owner(); } else { // Prefer embedded over owner. target_client = !embedded ? owning : embedded; @@ -213,7 +213,7 @@ class ServerWindowEventHandler : public ui::EventHandler { return true; 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 // window() is the the target. return true; @@ -245,10 +245,10 @@ class ServerWindowEventHandler : public ui::EventHandler { return false; // 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. - if (server_window_->DoesOwnerInterceptEvents()) { - server_window_->owning_window_tree()->SendEventToClient(window(), *event); + if (proxy_window_->DoesOwnerInterceptEvents()) { + proxy_window_->owning_window_tree()->SendEventToClient(window(), *event); if (event->cancelable()) event->StopPropagation(); return true; @@ -257,9 +257,9 @@ class ServerWindowEventHandler : public ui::EventHandler { } private: - ServerWindow* const server_window_; + ProxyWindow* const proxy_window_; - DISALLOW_COPY_AND_ASSIGN(ServerWindowEventHandler); + DISALLOW_COPY_AND_ASSIGN(ProxyWindowEventHandler); }; 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, // if a press occurs in the non-client area, then the event is not sent to // the client, it's handled locally. -class TopLevelEventHandler : public ServerWindowEventHandler { +class TopLevelEventHandler : public ProxyWindowEventHandler { public: - explicit TopLevelEventHandler(ServerWindow* server_window) - : ServerWindowEventHandler(server_window) { + explicit TopLevelEventHandler(ProxyWindow* proxy_window) + : ProxyWindowEventHandler(proxy_window) { // Top-levels should always have an owning_window_tree(). // OnEvent() assumes this. - DCHECK(server_window->owning_window_tree()); + DCHECK(proxy_window->owning_window_tree()); } ~TopLevelEventHandler() override = default; @@ -330,7 +330,7 @@ class TopLevelEventHandler : public ServerWindowEventHandler { pointer_press_handlers_.clear(); } - // ServerWindowEventHandler: + // ProxyWindowEventHandler: void OnEvent(ui::Event* event) override { if (event->phase() != ui::EP_PRETARGET) { // All work is done in the pre-phase. If this branch is hit, it means @@ -343,7 +343,7 @@ class TopLevelEventHandler : public ServerWindowEventHandler { return; if (!event->IsLocatedEvent()) { - ServerWindowEventHandler::OnEvent(event); + ProxyWindowEventHandler::OnEvent(event); return; } @@ -353,8 +353,8 @@ class TopLevelEventHandler : public ServerWindowEventHandler { // 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. if (wm::CaptureController::Get()->GetCaptureWindow()) { - if (server_window()->capture_owner()) { - server_window()->capture_owner()->SendEventToClient(window(), *event); + if (proxy_window()->capture_owner()) { + proxy_window()->capture_owner()->SendEventToClient(window(), *event); if (event->cancelable()) event->StopPropagation(); return; @@ -368,7 +368,7 @@ class TopLevelEventHandler : public ServerWindowEventHandler { // local, otherwise remote client. // . mouse-moves (not drags) go to both targets. bool stop_propagation = false; - if (server_window()->HasNonClientArea() && IsPointerEvent(*event)) { + if (proxy_window()->HasNonClientArea() && IsPointerEvent(*event)) { const ui::PointerId pointer_id = GetPointerId(*event); if (!pointer_press_handlers_.count(pointer_id)) { if (IsPointerPressedEvent(*event)) { @@ -393,7 +393,7 @@ class TopLevelEventHandler : public ServerWindowEventHandler { stop_propagation = true; } } - server_window()->owning_window_tree()->SendEventToClient(window(), *event); + proxy_window()->owning_window_tree()->SendEventToClient(window(), *event); if (stop_propagation && event->cancelable()) event->StopPropagation(); } @@ -439,47 +439,47 @@ void PointerPressHandler::OnWindowVisibilityChanged(aura::Window* window, } // namespace -ServerWindow::~ServerWindow() { +ProxyWindow::~ProxyWindow() { // WindowTree/ClientRoot should have reset |attached_frame_sink_id_| before // the Window is destroyed. DCHECK(!attached_frame_sink_id_.is_valid()); } // static -ServerWindow* ServerWindow::Create(aura::Window* window, - WindowTree* tree, - const viz::FrameSinkId& frame_sink_id, - bool is_top_level) { +ProxyWindow* ProxyWindow::Create(aura::Window* window, + WindowTree* tree, + const viz::FrameSinkId& frame_sink_id, + bool is_top_level) { DCHECK(!GetMayBeNull(window)); // Owned by |window|. - ServerWindow* server_window = - new ServerWindow(window, tree, frame_sink_id, is_top_level); - return server_window; + ProxyWindow* proxy_window = + new ProxyWindow(window, tree, frame_sink_id, is_top_level); + return proxy_window; } // static -const ServerWindow* ServerWindow::GetMayBeNull(const aura::Window* window) { - return window ? window->GetProperty(kServerWindowKey) : nullptr; +const ProxyWindow* ProxyWindow::GetMayBeNull(const aura::Window* window) { + return window ? window->GetProperty(kProxyWindowKey) : nullptr; } -void ServerWindow::Destroy() { +void ProxyWindow::Destroy() { // 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. DCHECK(!owning_window_tree_); // static_cast is needed to determine which function SetProperty() applies // 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; } -const WindowTree* ServerWindow::embedded_window_tree() const { +const WindowTree* ProxyWindow::embedded_window_tree() const { return embedding_ ? embedding_->embedded_tree() : nullptr; } -void ServerWindow::SetClientArea( +void ProxyWindow::SetClientArea( const gfx::Insets& insets, const std::vector<gfx::Rect>& additional_client_areas) { if (client_area_ == insets && @@ -496,12 +496,12 @@ void ServerWindow::SetClientArea( client_root->SetClientAreaInsets(insets); } -void ServerWindow::SetHitTestInsets(const gfx::Insets& mouse, - const gfx::Insets& touch) { +void ProxyWindow::SetHitTestInsets(const gfx::Insets& mouse, + const gfx::Insets& touch) { window_targeter_->SetInsets(mouse, touch); } -void ServerWindow::SetCaptureOwner(WindowTree* owner) { +void ProxyWindow::SetCaptureOwner(WindowTree* owner) { capture_owner_ = owner; if (!IsTopLevel()) return; @@ -510,28 +510,28 @@ void ServerWindow::SetCaptureOwner(WindowTree* owner) { ->OnCaptureOwnerChanged(); } -void ServerWindow::StoreCursor(const ui::Cursor& cursor) { +void ProxyWindow::StoreCursor(const ui::Cursor& cursor) { cursor_ = cursor; } -bool ServerWindow::DoesOwnerInterceptEvents() const { +bool ProxyWindow::DoesOwnerInterceptEvents() const { 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); } -bool ServerWindow::HasNonClientArea() const { +bool ProxyWindow::HasNonClientArea() const { return owning_window_tree_ && owning_window_tree_->IsTopLevel(window_) && (!client_area_.IsEmpty() || !additional_client_areas_.empty()); } -bool ServerWindow::IsTopLevel() const { +bool ProxyWindow::IsTopLevel() const { return owning_window_tree_ && owning_window_tree_->IsTopLevel(window_); } -void ServerWindow::AttachCompositorFrameSink( +void ProxyWindow::AttachCompositorFrameSink( viz::mojom::CompositorFrameSinkRequest compositor_frame_sink, viz::mojom::CompositorFrameSinkClientPtr client) { attached_compositor_frame_sink_ = true; @@ -541,32 +541,32 @@ void ServerWindow::AttachCompositorFrameSink( frame_sink_id_, std::move(compositor_frame_sink), std::move(client)); } -void ServerWindow::SetDragDropDelegate( +void ProxyWindow::SetDragDropDelegate( std::unique_ptr<DragDropDelegate> drag_drop_delegate) { drag_drop_delegate_ = std::move(drag_drop_delegate); } -std::string ServerWindow::GetIdForDebugging() { +std::string ProxyWindow::GetIdForDebugging() { return owning_window_tree_ ? owning_window_tree_->ClientWindowIdForWindow(window_).ToString() : frame_sink_id_.ToString(); } -ServerWindow::ServerWindow(aura::Window* window, - WindowTree* tree, - const viz::FrameSinkId& frame_sink_id, - bool is_top_level) +ProxyWindow::ProxyWindow(aura::Window* window, + WindowTree* tree, + const viz::FrameSinkId& frame_sink_id, + bool is_top_level) : window_(window), owning_window_tree_(tree), frame_sink_id_(frame_sink_id) { - window_->SetProperty(kServerWindowKey, this); + window_->SetProperty(kProxyWindowKey, this); if (is_top_level) event_handler_ = std::make_unique<TopLevelEventHandler>(this); else - event_handler_ = std::make_unique<ServerWindowEventHandler>(this); - auto server_window_targeter = std::make_unique<ServerWindowTargeter>(this); - window_targeter_ = server_window_targeter.get(); - window_->SetEventTargeter(std::move(server_window_targeter)); + event_handler_ = std::make_unique<ProxyWindowEventHandler>(this); + auto proxy_window_targeter = std::make_unique<ProxyWindowTargeter>(this); + window_targeter_ = proxy_window_targeter.get(); + window_->SetEventTargeter(std::move(proxy_window_targeter)); // In order for a window to receive events it must have a target_handler() // (see Window::CanAcceptEvent()). Normally the delegate is the TargetHandler, // 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()); } -bool ServerWindow::IsHandlingPointerPressForTesting(ui::PointerId pointer_id) { +bool ProxyWindow::IsHandlingPointerPressForTesting(ui::PointerId pointer_id) { DCHECK(IsTopLevel()); return static_cast<TopLevelEventHandler*>(event_handler_.get()) ->IsHandlingPointerPress(pointer_id); diff --git a/services/ws/server_window.h b/services/ws/proxy_window.h similarity index 84% rename from services/ws/server_window.h rename to services/ws/proxy_window.h index 2ba55629424c3..aa72d098f850e 100644 --- a/services/ws/server_window.h +++ b/services/ws/proxy_window.h @@ -2,8 +2,8 @@ // 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_H_ -#define SERVICES_WS_SERVER_WINDOW_H_ +#ifndef SERVICES_WS_PROXY_WINDOW_H_ +#define SERVICES_WS_PROXY_WINDOW_H_ #include <string> #include <vector> @@ -36,29 +36,29 @@ class Embedding; class WindowTree; // 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. -class COMPONENT_EXPORT(WINDOW_SERVICE) ServerWindow { +class COMPONENT_EXPORT(WINDOW_SERVICE) ProxyWindow { public: - ~ServerWindow(); + ~ProxyWindow(); - // Creates a new ServerWindow. The lifetime of the ServerWindow is tied to - // that of the Window (the Window ends up owning the ServerWindow). + // Creates a new ProxyWindow. The lifetime of the ProxyWindow is tied to + // that of the Window (the Window ends up owning the ProxyWindow). // |is_top_level| is true if the window represents a top-level window. - static ServerWindow* Create(aura::Window* window, - WindowTree* tree, - const viz::FrameSinkId& frame_sink_id, - bool is_top_level); + static ProxyWindow* Create(aura::Window* window, + WindowTree* tree, + const viz::FrameSinkId& frame_sink_id, + bool is_top_level); - // Returns the ServerWindow associated with a window, null if not created yet. - static ServerWindow* GetMayBeNull(aura::Window* window) { - return const_cast<ServerWindow*>( + // Returns the ProxyWindow associated with a window, null if not created yet. + static ProxyWindow* GetMayBeNull(aura::Window* window) { + return const_cast<ProxyWindow*>( 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. - // The typical use case is ServerWindow is owned by the aura::Window, and + // Explicitly deletes this ProxyWindow. This should very rarely be called. + // The typical use case is ProxyWindow is owned by the aura::Window, and // deleted when the associated window is deleted. void Destroy(); @@ -143,12 +143,12 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) ServerWindow { std::string GetIdForDebugging(); private: - friend class ServerWindowTestHelper; + friend class ProxyWindowTestHelper; - ServerWindow(aura::Window*, - WindowTree* tree, - const viz::FrameSinkId& frame_sink_id, - bool is_top_level); + ProxyWindow(aura::Window*, + WindowTree* tree, + const viz::FrameSinkId& frame_sink_id, + bool is_top_level); // Forwards to TopLevelEventHandler, see it for details. // 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(). viz::FrameSinkId attached_frame_sink_id_; - DISALLOW_COPY_AND_ASSIGN(ServerWindow); + DISALLOW_COPY_AND_ASSIGN(ProxyWindow); }; } // namespace ws -#endif // SERVICES_WS_SERVER_WINDOW_H_ +#endif // SERVICES_WS_PROXY_WINDOW_H_ diff --git a/services/ws/proxy_window_test_helper.cc b/services/ws/proxy_window_test_helper.cc new file mode 100644 index 0000000000000..b2dea7074c78b --- /dev/null +++ b/services/ws/proxy_window_test_helper.cc @@ -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 diff --git a/services/ws/proxy_window_test_helper.h b/services/ws/proxy_window_test_helper.h new file mode 100644 index 0000000000000..ca3d7380f01e2 --- /dev/null +++ b/services/ws/proxy_window_test_helper.h @@ -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_ diff --git a/services/ws/server_window_unittest.cc b/services/ws/proxy_window_unittest.cc similarity index 95% rename from services/ws/server_window_unittest.cc rename to services/ws/proxy_window_unittest.cc index 47bd9cdbbd23b..aa819d385e4a3 100644 --- a/services/ws/server_window_unittest.cc +++ b/services/ws/proxy_window_unittest.cc @@ -2,7 +2,7 @@ // 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.h" +#include "services/ws/proxy_window.h" #include <memory> @@ -20,7 +20,7 @@ namespace ws { -TEST(ServerWindow, FindTargetForWindowWithEasyResizeTargeter) { +TEST(ProxyWindow, FindTargetForWindowWithEasyResizeTargeter) { WindowServiceTestSetup setup; std::unique_ptr<wm::EasyResizeWindowTargeter> easy_resize_window_targeter = std::make_unique<wm::EasyResizeWindowTargeter>( @@ -51,7 +51,7 @@ TEST(ServerWindow, FindTargetForWindowWithEasyResizeTargeter) { setup.root(), &mouse_event2)); } -TEST(ServerWindow, FindTargetForWindowWithResizeInset) { +TEST(ProxyWindow, FindTargetForWindowWithResizeInset) { WindowServiceTestSetup setup; aura::Window* top_level = @@ -89,7 +89,7 @@ TEST(ServerWindow, FindTargetForWindowWithResizeInset) { setup.root(), &mouse_event_2)); } -TEST(ServerWindow, SetClientAreaPropagatesToClientSurfaceEmbedder) { +TEST(ProxyWindow, SetClientAreaPropagatesToClientSurfaceEmbedder) { WindowServiceTestSetup setup; aura::Window* top_level = diff --git a/services/ws/server_window_test_helper.cc b/services/ws/server_window_test_helper.cc deleted file mode 100644 index 9387973e287a7..0000000000000 --- a/services/ws/server_window_test_helper.cc +++ /dev/null @@ -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 diff --git a/services/ws/server_window_test_helper.h b/services/ws/server_window_test_helper.h deleted file mode 100644 index 7362330d7d260..0000000000000 --- a/services/ws/server_window_test_helper.h +++ /dev/null @@ -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_ diff --git a/services/ws/window_delegate_impl.cc b/services/ws/window_delegate_impl.cc index c2ce64b239c1a..416ed56646c65 100644 --- a/services/ws/window_delegate_impl.cc +++ b/services/ws/window_delegate_impl.cc @@ -5,7 +5,7 @@ #include "services/ws/window_delegate_impl.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_tree.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 // if it's not an embedded client. This is done to match the behavior of Aura, // which sets the cursor on the root. - for (ServerWindow* server_window = ServerWindow::GetMayBeNull(window_); - server_window; server_window = ServerWindow::GetMayBeNull( - server_window->window()->parent())) { - if (server_window->IsTopLevel()) { - if (server_window->window() == window_) - return server_window->cursor(); + for (ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window_); + proxy_window; proxy_window = ProxyWindow::GetMayBeNull( + proxy_window->window()->parent())) { + if (proxy_window->IsTopLevel()) { + if (proxy_window->window() == window_) + return proxy_window->cursor(); gfx::Point toplevel_point = point; - aura::Window::ConvertPointToTarget(window_, server_window->window(), + aura::Window::ConvertPointToTarget(window_, proxy_window->window(), &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 // for the cursor (which is the case with content embeddings). - if (server_window->HasEmbedding() && - !server_window->embedding()->embedding_tree_intercepts_events()) { - return server_window->cursor(); + if (proxy_window->HasEmbedding() && + !proxy_window->embedding()->embedding_tree_intercepts_events()) { + return proxy_window->cursor(); } } @@ -90,10 +90,10 @@ void WindowDelegateImpl::OnWindowTargetVisibilityChanged(bool visible) {} void WindowDelegateImpl::OnWindowOcclusionChanged( aura::Window::OcclusionState occlusion_state, const SkRegion&) { - ServerWindow* const server_window = ServerWindow::GetMayBeNull(window_); + ProxyWindow* const proxy_window = ProxyWindow::GetMayBeNull(window_); // TODO: Send occluded region. - if (server_window) - server_window->owning_window_tree()->SendOcclusionState(window_); + if (proxy_window) + proxy_window->owning_window_tree()->SendOcclusionState(window_); } bool WindowDelegateImpl::HasHitTestMask() const { diff --git a/services/ws/window_service.cc b/services/ws/window_service.cc index 9c07323f33d91..b667a8a470801 100644 --- a/services/ws/window_service.cc +++ b/services/ws/window_service.cc @@ -15,11 +15,11 @@ #include "services/ws/event_injector.h" #include "services/ws/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/mojom/window_manager.mojom.h" #include "services/ws/remoting_event_injector.h" #include "services/ws/screen_provider.h" -#include "services/ws/server_window.h" #include "services/ws/user_activity_monitor.h" #include "services/ws/window_server_test_impl.h" #include "services/ws/window_service_delegate.h" @@ -36,9 +36,9 @@ namespace ws { namespace { -// Returns true if |window| has remote client and marked as has-content. -bool IsRemoteOpaqueWindow(const aura::Window* window) { - return WindowService::HasRemoteClient(window) && +// Returns true if |window| is a proxy window and marked as has-content. +bool IsOpaqueProxyWindow(const aura::Window* window) { + return WindowService::IsProxyWindow(window) && window->GetProperty(aura::client::kClientWindowHasContent); } @@ -77,7 +77,7 @@ WindowService::WindowService( // Extends WindowOcclusionTracker to check whether remote window has content. env_->GetWindowOcclusionTracker()->set_window_has_content_callback( - base::BindRepeating(&IsRemoteOpaqueWindow)); + base::BindRepeating(&IsOpaqueProxyWindow)); } WindowService::~WindowService() { @@ -95,17 +95,17 @@ void WindowService::BindServiceRequest( service_binding_.Bind(std::move(request)); } -ServerWindow* WindowService::GetServerWindowForWindowCreateIfNecessary( +ProxyWindow* WindowService::GetProxyWindowForWindowCreateIfNecessary( aura::Window* window) { - ServerWindow* server_window = ServerWindow::GetMayBeNull(window); - if (server_window) - return server_window; + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window); + if (proxy_window) + return proxy_window; const viz::FrameSinkId frame_sink_id = ClientWindowId(kWindowServerClientId, next_window_id_++); CHECK_NE(0u, next_window_id_); 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( @@ -133,14 +133,14 @@ void WindowService::SetDisplayForNewWindows(int64_t display_id) { } // static -bool WindowService::HasRemoteClient(const aura::Window* window) { - return ServerWindow::GetMayBeNull(window); +bool WindowService::IsProxyWindow(const aura::Window* window) { + return ProxyWindow::GetMayBeNull(window); } // static bool WindowService::IsTopLevelWindow(const aura::Window* window) { - const ServerWindow* server_window = ServerWindow::GetMayBeNull(window); - return server_window && server_window->IsTopLevel(); + const ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window); + return proxy_window && proxy_window->IsTopLevel(); } aura::Window* WindowService::GetWindowByClientId(Id transport_id) { @@ -151,18 +151,18 @@ aura::Window* WindowService::GetWindowByClientId(Id transport_id) { } Id WindowService::GetCompleteTransportIdForWindow(aura::Window* window) { - ServerWindow* server_window = ServerWindow::GetMayBeNull(window); - if (!server_window) + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window); + if (!proxy_window) return kInvalidTransportId; - if (!server_window->owning_window_tree()) + if (!proxy_window->owning_window_tree()) return kInvalidTransportId; // 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 // real client_id, so it has to build it. return BuildTransportId( - server_window->owning_window_tree()->client_id(), + proxy_window->owning_window_tree()->client_id(), ClientWindowIdFromTransportId( - server_window->owning_window_tree()->TransportIdForWindow(window))); + proxy_window->owning_window_tree()->TransportIdForWindow(window))); } WindowService::TreeAndWindowId @@ -188,7 +188,7 @@ bool WindowService::CompleteScheduleEmbedForExistingClient( // Caller must supply a window, and further the window should not be exposed // to a remote client yet. DCHECK(window); - DCHECK(!HasRemoteClient(window)); + DCHECK(!IsProxyWindow(window)); const TreeAndWindowId tree_and_id = FindTreeWithScheduleEmbedForExistingClient(embed_token); @@ -199,14 +199,13 @@ bool WindowService::CompleteScheduleEmbedForExistingClient( DCHECK(!(embed_flags & mojom::kEmbedFlagEmbedderInterceptsEvents)); const bool owner_intercept_events = false; - ServerWindow* server_window = - GetServerWindowForWindowCreateIfNecessary(window); + ProxyWindow* proxy_window = GetProxyWindowForWindowCreateIfNecessary(window); tree_and_id.tree->CompleteScheduleEmbedForExistingClient( window, tree_and_id.id, embed_token); std::unique_ptr<Embedding> embedding = std::make_unique<Embedding>(nullptr, window, owner_intercept_events); embedding->InitForEmbedInExistingTree(tree_and_id.tree); - server_window->SetEmbedding(std::move(embedding)); + proxy_window->SetEmbedding(std::move(embedding)); return true; } @@ -231,11 +230,11 @@ void WindowService::OnWillDestroyWindowTree(WindowTree* tree) { } bool WindowService::RequestClose(aura::Window* window) { - ServerWindow* server_window = ServerWindow::GetMayBeNull(window); - if (!server_window || !server_window->IsTopLevel()) + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window); + if (!proxy_window || !proxy_window->IsTopLevel()) return false; - server_window->owning_window_tree()->RequestClose(server_window); + proxy_window->owning_window_tree()->RequestClose(proxy_window); return true; } @@ -245,10 +244,10 @@ void WindowService::OnDisplayMetricsChanged(const display::Display& display, } std::string WindowService::GetIdForDebugging(aura::Window* window) { - ServerWindow* server_window = ServerWindow::GetMayBeNull(window); - if (!server_window) + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window); + if (!proxy_window) return std::string(); - return server_window->GetIdForDebugging(); + return proxy_window->GetIdForDebugging(); } std::unique_ptr<HostEventQueue> WindowService::RegisterHostEventDispatcher( diff --git a/services/ws/window_service.h b/services/ws/window_service.h index e9f59eb0fd7b4..212f4bc80de6e 100644 --- a/services/ws/window_service.h +++ b/services/ws/window_service.h @@ -65,7 +65,7 @@ class HostEventDispatcher; class HostEventQueue; class RemotingEventInjector; class ScreenProvider; -class ServerWindow; +class ProxyWindow; class UserActivityMonitor; class WindowServiceDelegate; class WindowServiceObserver; @@ -93,8 +93,8 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowService // Manger. void BindServiceRequest(service_manager::mojom::ServiceRequest request); - // Gets the ServerWindow for |window|, creating if necessary. - ServerWindow* GetServerWindowForWindowCreateIfNecessary(aura::Window* window); + // Gets the ProxyWindow for |window|, creating if necessary. + ProxyWindow* GetProxyWindowForWindowCreateIfNecessary(aura::Window* window); // Creates a new WindowTree, caller must call one of the Init() functions on // the returned object. @@ -110,8 +110,8 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowService // over mojo to all remote clients. void SetDisplayForNewWindows(int64_t display_id); - // Whether |window| hosts a remote client. - static bool HasRemoteClient(const aura::Window* window); + // Returns true if |window| is a proxy window. + static bool IsProxyWindow(const aura::Window* window); // Returns true if |window| hosts a remote client and is a toplevel window. static bool IsTopLevelWindow(const aura::Window* window); @@ -179,7 +179,7 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowService aura::WindowTreeHost* window_tree_host, HostEventDispatcher* dispatcher); - // Returns an id useful for debugging. See ServerWindow::GetIdForDebugging() + // Returns an id useful for debugging. See ProxyWindow::GetIdForDebugging() // for details. std::string GetIdForDebugging(aura::Window* window); diff --git a/services/ws/window_service_unittest.cc b/services/ws/window_service_unittest.cc index 619d2cf060c10..0664bb853913b 100644 --- a/services/ws/window_service_unittest.cc +++ b/services/ws/window_service_unittest.cc @@ -200,7 +200,7 @@ TEST(WindowServiceTest, ScheduleEmbedForExistingClientUsingLocalWindow) { local_window->Init(ui::LAYER_NOT_DRAWN); ASSERT_TRUE(setup.service()->CompleteScheduleEmbedForExistingClient( local_window.get(), token, /* embed_flags */ 0)); - EXPECT_TRUE(WindowService::HasRemoteClient(local_window.get())); + EXPECT_TRUE(WindowService::IsProxyWindow(local_window.get())); } TEST(WindowServiceTest, @@ -227,11 +227,11 @@ TEST(WindowServiceTest, local_window->Init(ui::LAYER_NOT_DRAWN); ASSERT_TRUE(setup.service()->CompleteScheduleEmbedForExistingClient( 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(); - EXPECT_FALSE(WindowService::HasRemoteClient(local_window.get())); + EXPECT_FALSE(WindowService::IsProxyWindow(local_window.get())); } } // namespace ws diff --git a/services/ws/window_tree.cc b/services/ws/window_tree.cc index 9d424bf65dce4..b2e2ece203ac6 100644 --- a/services/ws/window_tree.cc +++ b/services/ws/window_tree.cc @@ -21,8 +21,8 @@ #include "services/ws/drag_drop_delegate.h" #include "services/ws/embedding.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/server_window.h" #include "services/ws/topmost_window_observer.h" #include "services/ws/window_delegate_impl.h" #include "services/ws/window_manager_interface.h" @@ -128,10 +128,10 @@ WindowTree::~WindowTree() { void WindowTree::InitForEmbed(aura::Window* root, mojom::WindowTreePtr window_tree_ptr) { - // Force ServerWindow to be created for |root|. - ServerWindow* server_window = - window_service_->GetServerWindowForWindowCreateIfNecessary(root); - const ClientWindowId client_window_id = server_window->frame_sink_id(); + // Force ProxyWindow to be created for |root|. + ProxyWindow* proxy_window = + window_service_->GetProxyWindowForWindowCreateIfNecessary(root); + const ClientWindowId client_window_id = proxy_window->frame_sink_id(); AddWindowToKnownWindows(root, client_window_id, nullptr); const bool is_top_level = false; ClientRoot* client_root = CreateClientRoot(root, is_top_level); @@ -144,11 +144,11 @@ void WindowTree::InitForEmbed(aura::Window* root, window_tree_client_->OnEmbed(WindowToWindowData(root), std::move(window_tree_ptr), display_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 // 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(); } @@ -160,7 +160,7 @@ void WindowTree::InitFromFactory() { void WindowTree::SendEventToClient(aura::Window* window, const ui::Event& event) { // 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. DCHECK(!event.IsGestureEvent()); @@ -211,7 +211,7 @@ void WindowTree::SendEventToClient(aura::Window* window, } } DVLOG(4) << "SendEventToClient window=" - << ServerWindow::GetMayBeNull(window)->GetIdForDebugging() + << ProxyWindow::GetMayBeNull(window)->GetIdForDebugging() << " event_type=" << ui::EventTypeName(event.type()) << " event_id=" << event_id; window_tree_client_->OnWindowInputEvent( @@ -250,7 +250,7 @@ aura::Window* WindowTree::GetWindowByTransportId(Id transport_window_id) { return GetWindowByClientId(MakeClientWindowId(transport_window_id)); } -void WindowTree::RequestClose(ServerWindow* window) { +void WindowTree::RequestClose(ProxyWindow* window) { DCHECK(window->IsTopLevel()); DCHECK_EQ(this, window->owning_window_tree()); window_tree_client_->RequestClose(TransportIdForWindow(window->window())); @@ -288,26 +288,26 @@ void WindowTree::CompleteScheduleEmbedForExistingClient( const bool is_top_level = false; ClientRoot* client_root = CreateClientRoot(window, is_top_level); - ServerWindow* server_window = ServerWindow::GetMayBeNull(window); - // It's expected we only get here if a ServerWindow exists for |window|. - DCHECK(server_window); + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window); + // It's expected we only get here if a ProxyWindow exists for |window|. + DCHECK(proxy_window); const int64_t display_id = display::Screen::GetScreen()->GetDisplayNearestWindow(window).id(); window_tree_client_->OnEmbedFromToken(token, WindowToWindowData(window), display_id, - server_window->local_surface_id()); + proxy_window->local_surface_id()); // 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. - server_window->set_frame_sink_id(id); + proxy_window->set_frame_sink_id(id); client_root->RegisterVizEmbeddingSupport(); } bool WindowTree::HasAtLeastOneRootWithCompositorFrameSink() { for (auto& client_root : client_roots_) { - if (ServerWindow::GetMayBeNull(client_root->window()) + if (ProxyWindow::GetMayBeNull(client_root->window()) ->attached_compositor_frame_sink()) { return true; } @@ -340,11 +340,11 @@ ClientRoot* WindowTree::CreateClientRoot(aura::Window* window, DCHECK(window); // Only one client may be embedded in a window at a time. - ServerWindow* server_window = - window_service_->GetServerWindowForWindowCreateIfNecessary(window); - if (server_window->embedded_window_tree()) { - server_window->embedded_window_tree()->DeleteClientRootWithRoot(window); - DCHECK(!server_window->embedded_window_tree()); + ProxyWindow* proxy_window = + window_service_->GetProxyWindowForWindowCreateIfNecessary(window); + if (proxy_window->embedded_window_tree()) { + proxy_window->embedded_window_tree()->DeleteClientRootWithRoot(window); + DCHECK(!proxy_window->embedded_window_tree()); } // Because a new client is being embedded all existing children are removed. @@ -362,12 +362,12 @@ void WindowTree::DeleteClientRoot(ClientRoot* client_root, DeleteClientRootReason reason) { aura::Window* window = client_root->window(); - ServerWindow* server_window = ServerWindow::GetMayBeNull(window); - client_root->UnattachChildFrameSinkIdRecursive(server_window); - if (server_window->capture_owner() == this) { + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window); + client_root->UnattachChildFrameSinkIdRecursive(proxy_window); + if (proxy_window->capture_owner() == this) { // This client will no longer know about |window|, so it should not receive // 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 @@ -407,25 +407,24 @@ void WindowTree::DeleteClientRoot(ClientRoot* client_root, if (reason == DeleteClientRootReason::kUnembed || reason == DeleteClientRootReason::kDestructor) { // Notify the owner of the window it no longer has a client embedded in it. - ServerWindow* server_window = ServerWindow::GetMayBeNull(window); - if (server_window->owning_window_tree() && - server_window->owning_window_tree() != this) { - // ClientRoots always trigger creation of a ServerWindow, so - // |server_window| must exist at this point. - DCHECK(server_window); - server_window->owning_window_tree() + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window); + if (proxy_window->owning_window_tree() && + proxy_window->owning_window_tree() != this) { + // ClientRoots always trigger creation of a ProxyWindow, so + // |proxy_window| must exist at this point. + DCHECK(proxy_window); + proxy_window->owning_window_tree() ->window_tree_client_->OnEmbeddedAppDisconnected( - server_window->owning_window_tree()->TransportIdForWindow( - window)); + proxy_window->owning_window_tree()->TransportIdForWindow(window)); } - if (server_window->embedding()) - server_window->embedding()->clear_embedded_tree(); + if (proxy_window->embedding()) + proxy_window->embedding()->clear_embedded_tree(); // Only reset the embedding if it's for an existing tree. To do otherwise // results in trying to delete this. - if (server_window->embedding() && !server_window->embedding()->binding()) { - server_window->SetEmbedding(nullptr); - if (!server_window->owning_window_tree()) - server_window->Destroy(); + if (proxy_window->embedding() && !proxy_window->embedding()->binding()) { + proxy_window->SetEmbedding(nullptr); + if (!proxy_window->owning_window_tree()) + proxy_window->Destroy(); } } } @@ -474,17 +473,17 @@ WindowTree::ClientRoots::iterator WindowTree::FindClientRootWithRoot( } bool WindowTree::IsWindowRootOfAnotherClient(aura::Window* window) const { - ServerWindow* server_window = ServerWindow::GetMayBeNull(window); - return server_window && server_window->embedded_window_tree() != nullptr && - server_window->embedded_window_tree() != this; + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window); + return proxy_window && proxy_window->embedded_window_tree() != nullptr && + proxy_window->embedded_window_tree() != this; } -bool WindowTree::DoesAnyAncestorInterceptEvents(ServerWindow* window) { +bool WindowTree::DoesAnyAncestorInterceptEvents(ProxyWindow* window) { if (window->embedding() && window->embedding()->embedding_tree() != this && window->embedding()->embedding_tree_intercepts_events()) { return true; } - ServerWindow* parent = ServerWindow::GetMayBeNull(window->window()->parent()); + ProxyWindow* parent = ProxyWindow::GetMayBeNull(window->window()->parent()); return parent && DoesAnyAncestorInterceptEvents(parent); } @@ -559,7 +558,7 @@ aura::Window* WindowTree::AddClientCreatedWindow( bool is_top_level, std::unique_ptr<aura::Window> window_ptr) { 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)); return window; } @@ -584,12 +583,12 @@ void WindowTree::RemoveWindowFromKnownWindows(aura::Window* window, bool delete_if_owned) { DCHECK(IsWindowKnown(window)); - ServerWindow* server_window = ServerWindow::GetMayBeNull(window); + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window); ClientRoot* client_root = FindClientRootContaining(window); 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); DCHECK(iter != known_windows_map_.end()); @@ -606,7 +605,7 @@ void WindowTree::RemoveWindowFromKnownWindows(aura::Window* window, DCHECK(iter == known_windows_map_.find(window)); // 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()); client_window_id_to_window_map_.erase(iter->second.client_window_id); known_windows_map_.erase(iter); @@ -707,9 +706,8 @@ WindowTree::GetAndRemoveScheduledEmbedWindowTreeClient( visited_trees->insert(this); for (auto& client_root : client_roots_) { - ServerWindow* root_window = - ServerWindow::GetMayBeNull(client_root->window()); - DCHECK(root_window); // There should always be a ServerWindow for a root. + ProxyWindow* root_window = ProxyWindow::GetMayBeNull(client_root->window()); + DCHECK(root_window); // There should always be a ProxyWindow for a root. WindowTree* owning_tree = root_window->owning_window_tree(); if (owning_tree) { auto result = owning_tree->GetAndRemoveScheduledEmbedWindowTreeClient( @@ -814,9 +812,9 @@ bool WindowTree::SetCaptureImpl(const ClientWindowId& window_id) { 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 // allowed to set capture. This is primarily to prevent renderers from // setting capture. @@ -828,20 +826,20 @@ bool WindowTree::SetCaptureImpl(const ClientWindowId& window_id) { DCHECK(capture_controller); 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 - // 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. - if (server_window->capture_owner()) - server_window->capture_owner()->OnCaptureLost(window); - server_window->SetCaptureOwner(this); + if (proxy_window->capture_owner()) + proxy_window->capture_owner()->OnCaptureLost(window); + proxy_window->SetCaptureOwner(this); } return true; } ClientChange change(property_change_tracker_.get(), window, ClientChangeType::kCapture); - server_window->SetCaptureOwner(this); + proxy_window->SetCaptureOwner(this); capture_controller->SetCapture(window); return capture_controller->GetCaptureWindow() == window; } @@ -870,14 +868,13 @@ bool WindowTree::ReleaseCaptureImpl(const ClientWindowId& window_id) { return false; } - ServerWindow* server_window = ServerWindow::GetMayBeNull(window); - if (server_window->capture_owner() && - server_window->capture_owner() != this) { + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window); + if (proxy_window->capture_owner() && proxy_window->capture_owner() != this) { // This client is trying to release capture, but it doesn't own capture. DVLOG(1) << "ReleaseCapture failed (client did not request capture)"; return false; } - server_window->SetCaptureOwner(nullptr); + proxy_window->SetCaptureOwner(nullptr); ClientChange change(property_change_tracker_.get(), window, ClientChangeType::kCapture); @@ -1126,10 +1123,10 @@ bool WindowTree::EmbedImpl(const ClientWindowId& window_id, base::Unretained(this), embedding.get())); if (flags & mojom::kEmbedFlagEmbedderControlsVisibility) embedding->embedded_tree()->can_change_root_window_visibility_ = false; - ServerWindow* server_window = ServerWindow::GetMayBeNull(window); - server_window->SetEmbedding(std::move(embedding)); + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window); + proxy_window->SetEmbedding(std::move(embedding)); window_tree_client_->OnFrameSinkIdAllocated( - ClientWindowIdToTransportId(window_id), server_window->frame_sink_id()); + ClientWindowIdToTransportId(window_id), proxy_window->frame_sink_id()); return true; } @@ -1170,11 +1167,11 @@ bool WindowTree::SetWindowBoundsImpl( return false; } - ServerWindow* server_window = ServerWindow::GetMayBeNull(window); + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window); const gfx::Rect original_bounds = IsTopLevel(window) ? window->GetBoundsInScreen() : window->bounds(); 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) return true; @@ -1183,7 +1180,7 @@ bool WindowTree::SetWindowBoundsImpl( ClientChangeType::kBounds); if (IsLocalSurfaceIdAssignedByClient(window)) - server_window->set_local_surface_id(local_surface_id); + proxy_window->set_local_surface_id(local_surface_id); if (IsTopLevel(window)) { display::Display dst_display = @@ -1208,9 +1205,9 @@ bool WindowTree::SetWindowBoundsImpl( if (local_surface_id_changed) { // If the bounds didn't change, but the LocalSurfaceId did, then the // LocalSurfaceId needs to be propagated to any embeddings. - if (server_window->HasEmbedding() && - server_window->embedding()->embedding_tree() == this) { - WindowTree* embedded_tree = server_window->embedding()->embedded_tree(); + if (proxy_window->HasEmbedding() && + proxy_window->embedding()->embedding_tree() == this) { + WindowTree* embedded_tree = proxy_window->embedding()->embedded_tree(); ClientRoot* embedded_client_root = embedded_tree->GetClientRootForWindow(window); DCHECK(embedded_client_root); @@ -1221,7 +1218,7 @@ bool WindowTree::SetWindowBoundsImpl( } if (window->bounds() == bounds && - server_window->local_surface_id() == local_surface_id) { + proxy_window->local_surface_id() == local_surface_id) { return true; } @@ -1283,7 +1280,7 @@ bool WindowTree::SetCursorImpl(const ClientWindowId& window_id, return false; } - auto* server_window = ServerWindow::GetMayBeNull(window); + auto* proxy_window = ProxyWindow::GetMayBeNull(window); 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). if (!window_service_->delegate()->StoreAndSetCursor(window, 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. - server_window->StoreCursor(old_cursor_type); + proxy_window->StoreCursor(old_cursor_type); } return true; @@ -1343,7 +1340,7 @@ void WindowTree::GetWindowTreeRecursive(aura::Window* window, } void WindowTree::OnEmbeddedClientConnectionLost(Embedding* embedding) { - ServerWindow::GetMayBeNull(embedding->window())->SetEmbedding(nullptr); + ProxyWindow::GetMayBeNull(embedding->window())->SetEmbedding(nullptr); } void WindowTree::OnWindowHierarchyChanging( @@ -1351,17 +1348,17 @@ void WindowTree::OnWindowHierarchyChanging( if (params.target != params.receiver || !IsClientCreatedWindow(params.target)) return; - ServerWindow* server_window = ServerWindow::GetMayBeNull(params.target); - DCHECK(server_window); // non-null because of IsClientCreatedWindow() check. + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(params.target); + DCHECK(proxy_window); // non-null because of IsClientCreatedWindow() check. ClientRoot* old_root = FindClientRootContaining(params.old_parent); ClientRoot* new_root = FindClientRootContaining(params.new_parent); if (old_root == new_root) return; if (old_root) - old_root->UnattachChildFrameSinkIdRecursive(server_window); + old_root->UnattachChildFrameSinkIdRecursive(proxy_window); if (new_root) - new_root->AttachChildFrameSinkIdRecursive(server_window); + new_root->AttachChildFrameSinkIdRecursive(proxy_window); } void WindowTree::OnWindowDestroyed(aura::Window* window) { @@ -1410,12 +1407,12 @@ void WindowTree::OnCaptureChanged(aura::Window* lost_capture, // another window. if (lost_capture && (IsClientCreatedWindow(lost_capture) || IsClientRootWindow(lost_capture))) { - ServerWindow* server_window = ServerWindow::GetMayBeNull(lost_capture); - if (server_window->capture_owner() == this) { + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(lost_capture); + if (proxy_window->capture_owner() == this) { // 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 // capture, an invalid window id is used. - server_window->SetCaptureOwner(nullptr); + proxy_window->SetCaptureOwner(nullptr); const Id gained_capture_id = gained_capture && IsWindowKnown(gained_capture) && !IsClientRootWindow(gained_capture) @@ -1472,8 +1469,8 @@ void WindowTree::NewTopLevelWindow( const bool is_top_level = true; aura::Window* top_level = AddClientCreatedWindow( client_window_id, is_top_level, std::move(top_level_ptr)); - ServerWindow* top_level_server_window = ServerWindow::GetMayBeNull(top_level); - top_level_server_window->set_frame_sink_id(client_window_id); + ProxyWindow* top_level_proxy_window = ProxyWindow::GetMayBeNull(top_level); + top_level_proxy_window->set_frame_sink_id(client_window_id); const int64_t display_id = display::Screen::GetScreen()->GetDisplayNearestWindow(top_level).id(); // 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(); window_tree_client_->OnTopLevelCreated( 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) { @@ -1550,9 +1547,9 @@ void WindowTree::SetClientArea( return; } - ServerWindow* server_window = ServerWindow::GetMayBeNull(window); - DCHECK(server_window); // Must exist because of preceding conditionals. - server_window->SetClientArea( + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window); + DCHECK(proxy_window); // Must exist because of preceding conditionals. + proxy_window->SetClientArea( insets, additional_client_areas.value_or(std::vector<gfx::Rect>())); } @@ -1572,10 +1569,10 @@ void WindowTree::SetHitTestInsets(Id transport_window_id, return; } - ServerWindow* server_window = ServerWindow::GetMayBeNull(window); - DCHECK(server_window); // Must exist because of preceding conditionals. - server_window->SetHitTestInsets(MakeInsetsPositive(mouse), - MakeInsetsPositive(touch)); + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window); + DCHECK(proxy_window); // Must exist because of preceding conditionals. + proxy_window->SetHitTestInsets(MakeInsetsPositive(mouse), + MakeInsetsPositive(touch)); } 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)"; return; } - ServerWindow* server_window = ServerWindow::GetMayBeNull(window); - DCHECK(server_window); // Must exist because of preceding conditionals. - if (server_window->attached_frame_sink_id() == f) + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window); + DCHECK(proxy_window); // Must exist because of preceding conditionals. + if (proxy_window->attached_frame_sink_id() == f) 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)"; return; } - server_window->set_attached_frame_sink_id(f); + proxy_window->set_attached_frame_sink_id(f); ClientRoot* client_root = FindClientRootContaining(window); if (client_root) - client_root->AttachChildFrameSinkId(server_window); + client_root->AttachChildFrameSinkId(proxy_window); } 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)"; return; } - ServerWindow* server_window = ServerWindow::GetMayBeNull(window); - DCHECK(server_window); // Must exist because of preceding conditionals. - if (!server_window->attached_frame_sink_id().is_valid()) { + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window); + DCHECK(proxy_window); // Must exist because of preceding conditionals. + if (!proxy_window->attached_frame_sink_id().is_valid()) { DVLOG(3) << "UnattachFrameSinkId failed (frame sink already cleared)"; return; } ClientRoot* client_root = FindClientRootContaining(window); if (client_root) - client_root->UnattachChildFrameSinkId(server_window); - server_window->set_attached_frame_sink_id(viz::FrameSinkId()); + client_root->UnattachChildFrameSinkId(proxy_window); + proxy_window->set_attached_frame_sink_id(viz::FrameSinkId()); } void WindowTree::SetCanAcceptDrops(Id window_id, bool accepts_drops) { @@ -1635,16 +1632,16 @@ void WindowTree::SetCanAcceptDrops(Id window_id, bool accepts_drops) { return; } - ServerWindow* server_window = ServerWindow::GetMayBeNull(window); - DCHECK(server_window); // Must exist because of preceding conditionals. - if (accepts_drops && !server_window->HasDragDropDelegate()) { + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window); + DCHECK(proxy_window); // Must exist because of preceding conditionals. + if (accepts_drops && !proxy_window->HasDragDropDelegate()) { auto drag_drop_delegate = std::make_unique<DragDropDelegate>( window_tree_client_, window, window_id); aura::client::SetDragDropDelegate(window, drag_drop_delegate.get()); - server_window->SetDragDropDelegate(std::move(drag_drop_delegate)); - } else if (!accepts_drops && server_window->HasDragDropDelegate()) { + proxy_window->SetDragDropDelegate(std::move(drag_drop_delegate)); + } else if (!accepts_drops && proxy_window->HasDragDropDelegate()) { 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)"; 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 // another client embedded in the window. const bool allow = IsClientRootWindow(window) || (IsClientCreatedWindow(window) && - server_window->embedded_window_tree() == nullptr); + proxy_window->embedded_window_tree() == nullptr); if (!allow) { DVLOG(1) << "AttachCompositorFrameSink failed (policy disallowed)"; return; } - server_window->AttachCompositorFrameSink(std::move(compositor_frame_sink), - std::move(client)); + proxy_window->AttachCompositorFrameSink(std::move(compositor_frame_sink), + std::move(client)); } 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; } - ServerWindow* server_window = ServerWindow::GetMayBeNull(window); + ProxyWindow* proxy_window = ProxyWindow::GetMayBeNull(window); const bool owner_intercept_events = (connection_type_ != ConnectionType::kEmbedding && (embed_flags & mojom::kEmbedFlagEmbedderInterceptsEvents) != 0); @@ -1833,12 +1830,12 @@ void WindowTree::EmbedUsingToken(Id transport_window_id, std::unique_ptr<Embedding> embedding = std::make_unique<Embedding>(this, window, owner_intercept_events); 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 // client-id. window_tree_client_->OnFrameSinkIdAllocated( ClientWindowIdToTransportId(MakeClientWindowId(transport_window_id)), - server_window->frame_sink_id()); + proxy_window->frame_sink_id()); std::move(callback).Run(true); } diff --git a/services/ws/window_tree.h b/services/ws/window_tree.h index ed68b15228adc..5b8d29708a218 100644 --- a/services/ws/window_tree.h +++ b/services/ws/window_tree.h @@ -38,7 +38,7 @@ class ClientRoot; class Embedding; class EventObserverHelper; class FocusHandler; -class ServerWindow; +class ProxyWindow; class TopmostWindowObserver; class WindowManagerInterface; class WindowService; @@ -107,7 +107,7 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowTree bool IsTopLevel(aura::Window* 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 // 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; // 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. // |lost_capture| is the window that had capture. diff --git a/services/ws/window_tree_test_helper.cc b/services/ws/window_tree_test_helper.cc index fd8148063806e..f31bcc18b716c 100644 --- a/services/ws/window_tree_test_helper.cc +++ b/services/ws/window_tree_test_helper.cc @@ -4,7 +4,7 @@ #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" namespace ws { @@ -123,7 +123,7 @@ Embedding* WindowTreeTestHelper::Embed(aura::Window* window, std::move(client_ptr), client, embed_flags)) { return nullptr; } - return ServerWindow::GetMayBeNull(window)->embedding(); + return ProxyWindow::GetMayBeNull(window)->embedding(); } void WindowTreeTestHelper::SetEventTargetingPolicy( diff --git a/services/ws/window_tree_test_helper.h b/services/ws/window_tree_test_helper.h index 0e94a066bcc55..ab1aa77a73289 100644 --- a/services/ws/window_tree_test_helper.h +++ b/services/ws/window_tree_test_helper.h @@ -90,7 +90,7 @@ class WindowTreeTestHelper { uint32_t change_id = 1); // 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, mojom::WindowTreeClientPtr client_ptr, mojom::WindowTreeClient* client, diff --git a/services/ws/window_tree_unittest.cc b/services/ws/window_tree_unittest.cc index db57d2c7831d0..1323547e0ce01 100644 --- a/services/ws/window_tree_unittest.cc +++ b/services/ws/window_tree_unittest.cc @@ -15,10 +15,10 @@ #include "components/viz/host/host_frame_sink_manager.h" #include "components/viz/test/fake_host_frame_sink_client.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/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_service.h" #include "services/ws/window_service_test_setup.h" @@ -1218,17 +1218,16 @@ TEST(WindowTreeTest, PointerDownResetOnCaptureChange) { ui::test::EventGenerator event_generator(setup.root()); event_generator.MoveMouseTo(5, 5); event_generator.PressLeftButton(); - ServerWindow* top_level_server_window = ServerWindow::GetMayBeNull(top_level); - ASSERT_TRUE(top_level_server_window); - ServerWindowTestHelper top_level_server_window_helper( - top_level_server_window); - EXPECT_TRUE(top_level_server_window_helper.IsHandlingPointerPress( + ProxyWindow* top_level_proxy_window = ProxyWindow::GetMayBeNull(top_level); + ASSERT_TRUE(top_level_proxy_window); + ProxyWindowTestHelper top_level_proxy_window_helper(top_level_proxy_window); + EXPECT_TRUE(top_level_proxy_window_helper.IsHandlingPointerPress( ui::MouseEvent::kMousePointerId)); // Set capture on |window|, top_level should no longer be in pointer-down // (because capture changed). 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)); } @@ -1245,16 +1244,15 @@ TEST(WindowTreeTest, PointerDownResetOnHide) { ui::test::EventGenerator event_generator(setup.root()); event_generator.MoveMouseTo(5, 5); event_generator.PressLeftButton(); - ServerWindow* top_level_server_window = ServerWindow::GetMayBeNull(top_level); - ASSERT_TRUE(top_level_server_window); - ServerWindowTestHelper top_level_server_window_helper( - top_level_server_window); - EXPECT_TRUE(top_level_server_window_helper.IsHandlingPointerPress( + ProxyWindow* top_level_proxy_window = ProxyWindow::GetMayBeNull(top_level); + ASSERT_TRUE(top_level_proxy_window); + ProxyWindowTestHelper top_level_proxy_window_helper(top_level_proxy_window); + EXPECT_TRUE(top_level_proxy_window_helper.IsHandlingPointerPress( ui::MouseEvent::kMousePointerId)); // Hiding should implicitly cancel capture. top_level->Hide(); - EXPECT_FALSE(top_level_server_window_helper.IsHandlingPointerPress( + EXPECT_FALSE(top_level_proxy_window_helper.IsHandlingPointerPress( ui::MouseEvent::kMousePointerId)); } @@ -1342,7 +1340,7 @@ TEST(WindowTreeTest, Embed) { const Id embed_window_transport_id = setup.window_tree_test_helper()->TransportIdForWindow(embed_window); 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); } @@ -1543,10 +1541,10 @@ TEST(WindowTreeTest, DeleteEmbededTreeFromScheduleEmbedForExistingClient) { &embed_result)); EXPECT_TRUE(embed_callback_called); EXPECT_TRUE(embed_result); - EXPECT_TRUE(ServerWindow::GetMayBeNull(window_in_parent)->HasEmbedding()); + EXPECT_TRUE(ProxyWindow::GetMayBeNull(window_in_parent)->HasEmbedding()); tree2.reset(); - EXPECT_FALSE(ServerWindow::GetMayBeNull(window_in_parent)->HasEmbedding()); + EXPECT_FALSE(ProxyWindow::GetMayBeNull(window_in_parent)->HasEmbedding()); } TEST(WindowTreeTest, StackAtTop) { @@ -2044,15 +2042,15 @@ TEST(WindowTreeTest, DsfChanges) { setup.window_tree_test_helper()->NewTopLevelWindow(); ASSERT_TRUE(top_level); 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 = - top_level_server_window->local_surface_id(); + top_level_proxy_window->local_surface_id(); EXPECT_TRUE(initial_surface_id); // Changing the scale factor should change the LocalSurfaceId. setup.aura_test_helper()->test_screen()->SetDeviceScaleFactor(2.0f); - EXPECT_TRUE(top_level_server_window->local_surface_id()); - EXPECT_NE(*top_level_server_window->local_surface_id(), *initial_surface_id); + EXPECT_TRUE(top_level_proxy_window->local_surface_id()); + EXPECT_NE(*top_level_proxy_window->local_surface_id(), *initial_surface_id); } TEST(WindowTreeTest, DontSendGestures) { @@ -2142,16 +2140,16 @@ TEST(WindowTreeTest, AttachFrameSinkId) { test_frame_sink_id, &test_host_frame_sink_client, viz::ReportFirstSurfaceActivation::kYes); 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); 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)); // Removing the window should remove the association. top_level->RemoveChild(child_window); 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)); setup.window_tree_test_helper()->DeleteWindow(child_window);