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

Unified Diff: ui/aura/mus/window_tree_client.cc

Issue 2536943005: Adds couple of functions to WindowManagerDelegate: (Closed)
Patch Set: comment Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura/mus/window_tree_client.h ('k') | ui/aura/test/aura_test_base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/mus/window_tree_client.cc
diff --git a/ui/aura/mus/window_tree_client.cc b/ui/aura/mus/window_tree_client.cc
index 14c7d48da4af8d452c6d35c131bdc942ff96c630..6392a86607fd1dc801b2ce42a83e44447bf7e0cc 100644
--- a/ui/aura/mus/window_tree_client.cc
+++ b/ui/aura/mus/window_tree_client.cc
@@ -145,10 +145,12 @@ float ScaleFactorForDisplay(Window* window) {
} // namespace
WindowTreeClient::WindowTreeClient(
+ service_manager::Connector* connector,
WindowTreeClientDelegate* delegate,
WindowManagerDelegate* window_manager_delegate,
mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request)
- : client_id_(0),
+ : connector_(connector),
+ client_id_(0),
next_window_id_(1),
next_change_id_(1),
delegate_(delegate),
@@ -199,25 +201,23 @@ WindowTreeClient::~WindowTreeClient() {
client::GetTransientWindowClient()->RemoveObserver(this);
}
-void WindowTreeClient::ConnectViaWindowTreeFactory(
- service_manager::Connector* connector) {
+void WindowTreeClient::ConnectViaWindowTreeFactory() {
// The client id doesn't really matter, we use 101 purely for debugging.
client_id_ = 101;
ui::mojom::WindowTreeFactoryPtr factory;
- connector->ConnectToInterface(ui::mojom::kServiceName, &factory);
+ connector_->ConnectToInterface(ui::mojom::kServiceName, &factory);
ui::mojom::WindowTreePtr window_tree;
factory->CreateWindowTree(GetProxy(&window_tree),
binding_.CreateInterfacePtrAndBind());
SetWindowTree(std::move(window_tree));
}
-void WindowTreeClient::ConnectAsWindowManager(
- service_manager::Connector* connector) {
+void WindowTreeClient::ConnectAsWindowManager() {
DCHECK(window_manager_delegate_);
ui::mojom::WindowManagerWindowTreeFactoryPtr factory;
- connector->ConnectToInterface(ui::mojom::kServiceName, &factory);
+ connector_->ConnectToInterface(ui::mojom::kServiceName, &factory);
ui::mojom::WindowTreePtr window_tree;
factory->CreateWindowTree(GetProxy(&window_tree),
binding_.CreateInterfacePtrAndBind());
@@ -266,13 +266,6 @@ void WindowTreeClient::Embed(
tree_->Embed(window_id, std::move(client), flags, callback);
}
-void WindowTreeClient::RequestClose(Window* window) {
- DCHECK(window);
- if (window_manager_internal_client_)
- window_manager_internal_client_->WmRequestClose(
- WindowMus::Get(window)->server_id());
-}
-
void WindowTreeClient::AttachCompositorFrameSink(
Id window_id,
ui::mojom::CompositorFrameSinkType type,
@@ -293,13 +286,6 @@ WindowMus* WindowTreeClient::GetWindowByServerId(Id id) {
return it != windows_.end() ? it->second : nullptr;
}
-bool WindowTreeClient::WasCreatedByThisClient(const WindowMus* window) const {
- // Windows created via CreateTopLevelWindow() are not owned by us, but have
- // our client id. const_cast is required by set.
- return HiWord(window->server_id()) == client_id_ &&
- roots_.count(const_cast<WindowMus*>(window)) == 0;
-}
-
InFlightChange* WindowTreeClient::GetOldestInFlightChangeMatching(
const InFlightChange& change) {
for (const auto& pair : in_flight_map_) {
@@ -476,6 +462,8 @@ WindowTreeHost* WindowTreeClient::WmNewDisplayAddedImpl(
bool parent_drawn) {
DCHECK(window_manager_delegate_);
+ window_manager_delegate_->OnWmWillCreateDisplay(display);
+
std::unique_ptr<WindowTreeHostMus> window_tree_host =
CreateWindowTreeHost(WindowMusType::DISPLAY, root_data, display.id());
@@ -733,6 +721,13 @@ std::set<Window*> WindowTreeClient::GetRoots() {
return roots;
}
+bool WindowTreeClient::WasCreatedByThisClient(const WindowMus* window) const {
+ // Windows created via CreateTopLevelWindow() are not owned by us, but have
+ // our client id. const_cast is required by set.
+ return HiWord(window->server_id()) == client_id_ &&
+ roots_.count(const_cast<WindowMus*>(window)) == 0;
+}
+
gfx::Point WindowTreeClient::GetCursorScreenPoint() {
// We raced initialization. Return (0, 0).
if (!cursor_location_memory())
@@ -932,16 +927,20 @@ void WindowTreeClient::OnClientAreaChanged(
uint32_t window_id,
const gfx::Insets& new_client_area,
const std::vector<gfx::Rect>& new_additional_client_areas) {
- // TODO: client area.
- // TODO(riajiang): Convert from pixel to DIP. (http://crbug.com/600815)
- /*
- Window* window = GetWindowByServerId(window_id);
- if (window) {
- WindowPrivate(window).LocalSetClientArea(
- new_client_area,
- new_additional_client_areas);
+ WindowMus* window = GetWindowByServerId(window_id);
+ if (!window)
+ return;
+
+ float device_scale_factor = ScaleFactorForDisplay(window->GetWindow());
+ std::vector<gfx::Rect> new_additional_client_areas_in_dip;
+ for (const gfx::Rect& area : new_additional_client_areas) {
+ new_additional_client_areas_in_dip.push_back(
+ gfx::ConvertRectToDIP(device_scale_factor, area));
}
- */
+ window_manager_delegate_->OnWmSetClientArea(
+ window->GetWindow(),
+ gfx::ConvertInsetsToDIP(device_scale_factor, new_client_area),
+ new_additional_client_areas_in_dip);
}
void WindowTreeClient::OnTransientWindowAdded(uint32_t window_id,
@@ -1470,6 +1469,13 @@ void WindowTreeClient::SetUnderlaySurfaceOffsetAndExtendedHitArea(
}
}
+void WindowTreeClient::RequestClose(Window* window) {
+ DCHECK(window);
+ if (window_manager_internal_client_)
+ window_manager_internal_client_->WmRequestClose(
+ WindowMus::Get(window)->server_id());
+}
+
void WindowTreeClient::OnWindowTreeHostBoundsWillChange(
WindowTreeHostMus* window_tree_host,
const gfx::Rect& bounds) {
« no previous file with comments | « ui/aura/mus/window_tree_client.h ('k') | ui/aura/test/aura_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698