| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/mus/ws/server_window.h" | 5 #include "components/mus/ws/server_window.h" |
| 6 | 6 |
| 7 #include <inttypes.h> | 7 #include <inttypes.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "components/mus/common/transient_window_utils.h" | 11 #include "components/mus/common/transient_window_utils.h" |
| 12 #include "components/mus/public/interfaces/window_manager.mojom.h" |
| 12 #include "components/mus/ws/server_window_delegate.h" | 13 #include "components/mus/ws/server_window_delegate.h" |
| 13 #include "components/mus/ws/server_window_observer.h" | 14 #include "components/mus/ws/server_window_observer.h" |
| 14 #include "components/mus/ws/server_window_surface_manager.h" | 15 #include "components/mus/ws/server_window_surface_manager.h" |
| 15 #include "mojo/converters/geometry/geometry_type_converters.h" | 16 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 16 | 17 |
| 17 namespace mus { | 18 namespace mus { |
| 18 | 19 |
| 19 namespace ws { | 20 namespace ws { |
| 20 | 21 |
| 21 ServerWindow::ServerWindow(ServerWindowDelegate* delegate, const WindowId& id) | 22 ServerWindow::ServerWindow(ServerWindowDelegate* delegate, const WindowId& id) |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 if (value) { | 315 if (value) { |
| 315 properties_[name] = *value; | 316 properties_[name] = *value; |
| 316 } else if (it != properties_.end()) { | 317 } else if (it != properties_.end()) { |
| 317 properties_.erase(it); | 318 properties_.erase(it); |
| 318 } | 319 } |
| 319 | 320 |
| 320 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, | 321 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, |
| 321 OnWindowSharedPropertyChanged(this, name, value)); | 322 OnWindowSharedPropertyChanged(this, name, value)); |
| 322 } | 323 } |
| 323 | 324 |
| 325 std::string ServerWindow::GetName() const { |
| 326 auto it = properties_.find(mojom::WindowManager::kName_Property); |
| 327 if (it == properties_.end()) |
| 328 return std::string(); |
| 329 return std::string(it->second.begin(), it->second.end()); |
| 330 } |
| 331 |
| 324 void ServerWindow::SetTextInputState(const ui::TextInputState& state) { | 332 void ServerWindow::SetTextInputState(const ui::TextInputState& state) { |
| 325 const bool changed = !(text_input_state_ == state); | 333 const bool changed = !(text_input_state_ == state); |
| 326 if (changed) { | 334 if (changed) { |
| 327 text_input_state_ = state; | 335 text_input_state_ = state; |
| 328 // keyboard even if the state is not changed. So we have to notify | 336 // keyboard even if the state is not changed. So we have to notify |
| 329 // |observers_|. | 337 // |observers_|. |
| 330 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, | 338 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, |
| 331 OnWindowTextInputStateChanged(this, state)); | 339 OnWindowTextInputStateChanged(this, state)); |
| 332 } | 340 } |
| 333 } | 341 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 #if !defined(NDEBUG) | 379 #if !defined(NDEBUG) |
| 372 std::string ServerWindow::GetDebugWindowHierarchy() const { | 380 std::string ServerWindow::GetDebugWindowHierarchy() const { |
| 373 std::string result; | 381 std::string result; |
| 374 BuildDebugInfo(std::string(), &result); | 382 BuildDebugInfo(std::string(), &result); |
| 375 return result; | 383 return result; |
| 376 } | 384 } |
| 377 | 385 |
| 378 void ServerWindow::BuildDebugInfo(const std::string& depth, | 386 void ServerWindow::BuildDebugInfo(const std::string& depth, |
| 379 std::string* result) const { | 387 std::string* result) const { |
| 380 *result += base::StringPrintf( | 388 *result += base::StringPrintf( |
| 381 "%sid=%d,%d visible=%s bounds=%d,%d %dx%d" PRIu64 "\n", depth.c_str(), | 389 "%sid=%d,%d visible=%s bounds=%d,%d %dx%d name=%s\n", depth.c_str(), |
| 382 static_cast<int>(id_.connection_id), static_cast<int>(id_.window_id), | 390 static_cast<int>(id_.connection_id), static_cast<int>(id_.window_id), |
| 383 visible_ ? "true" : "false", bounds_.x(), bounds_.y(), bounds_.width(), | 391 visible_ ? "true" : "false", bounds_.x(), bounds_.y(), bounds_.width(), |
| 384 bounds_.height()); | 392 bounds_.height(), GetName().c_str()); |
| 385 for (const ServerWindow* child : children_) | 393 for (const ServerWindow* child : children_) |
| 386 child->BuildDebugInfo(depth + " ", result); | 394 child->BuildDebugInfo(depth + " ", result); |
| 387 } | 395 } |
| 388 #endif | 396 #endif |
| 389 | 397 |
| 390 void ServerWindow::RemoveImpl(ServerWindow* window) { | 398 void ServerWindow::RemoveImpl(ServerWindow* window) { |
| 391 window->parent_ = nullptr; | 399 window->parent_ = nullptr; |
| 392 children_.erase(std::find(children_.begin(), children_.end(), window)); | 400 children_.erase(std::find(children_.begin(), children_.end(), window)); |
| 393 } | 401 } |
| 394 | 402 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 } | 443 } |
| 436 | 444 |
| 437 // static | 445 // static |
| 438 ServerWindow** ServerWindow::GetStackingTarget(ServerWindow* window) { | 446 ServerWindow** ServerWindow::GetStackingTarget(ServerWindow* window) { |
| 439 return &window->stacking_target_; | 447 return &window->stacking_target_; |
| 440 } | 448 } |
| 441 | 449 |
| 442 } // namespace ws | 450 } // namespace ws |
| 443 | 451 |
| 444 } // namespace mus | 452 } // namespace mus |
| OLD | NEW |