Chromium Code Reviews| 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 namespace { | 22 namespace { |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 if (value) { | 339 if (value) { |
| 339 properties_[name] = *value; | 340 properties_[name] = *value; |
| 340 } else if (it != properties_.end()) { | 341 } else if (it != properties_.end()) { |
| 341 properties_.erase(it); | 342 properties_.erase(it); |
| 342 } | 343 } |
| 343 | 344 |
| 344 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, | 345 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, |
| 345 OnWindowSharedPropertyChanged(this, name, value)); | 346 OnWindowSharedPropertyChanged(this, name, value)); |
| 346 } | 347 } |
| 347 | 348 |
| 349 std::string ServerWindow::GetName() const { | |
| 350 auto it = properties_.find(mojom::WindowManager::kName_Property); | |
| 351 if (it == properties_.end()) | |
| 352 return std::string(); | |
| 353 return std::string(it->second.begin(), it->second.end()); | |
|
msw
2016/05/05 22:12:07
nit: use the property_type_converter?
James Cook
2016/05/05 22:53:18
I can't, property_type_converters.cc is in compone
msw
2016/05/05 23:10:06
Nah, I guess this is fine as-is.
| |
| 354 } | |
| 355 | |
| 348 void ServerWindow::SetTextInputState(const ui::TextInputState& state) { | 356 void ServerWindow::SetTextInputState(const ui::TextInputState& state) { |
| 349 const bool changed = !(text_input_state_ == state); | 357 const bool changed = !(text_input_state_ == state); |
| 350 if (changed) { | 358 if (changed) { |
| 351 text_input_state_ = state; | 359 text_input_state_ = state; |
| 352 // keyboard even if the state is not changed. So we have to notify | 360 // keyboard even if the state is not changed. So we have to notify |
| 353 // |observers_|. | 361 // |observers_|. |
| 354 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, | 362 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, |
| 355 OnWindowTextInputStateChanged(this, state)); | 363 OnWindowTextInputStateChanged(this, state)); |
| 356 } | 364 } |
| 357 } | 365 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 395 #if !defined(NDEBUG) | 403 #if !defined(NDEBUG) |
| 396 std::string ServerWindow::GetDebugWindowHierarchy() const { | 404 std::string ServerWindow::GetDebugWindowHierarchy() const { |
| 397 std::string result; | 405 std::string result; |
| 398 BuildDebugInfo(std::string(), &result); | 406 BuildDebugInfo(std::string(), &result); |
| 399 return result; | 407 return result; |
| 400 } | 408 } |
| 401 | 409 |
| 402 void ServerWindow::BuildDebugInfo(const std::string& depth, | 410 void ServerWindow::BuildDebugInfo(const std::string& depth, |
| 403 std::string* result) const { | 411 std::string* result) const { |
| 404 *result += base::StringPrintf( | 412 *result += base::StringPrintf( |
| 405 "%sid=%d,%d visible=%s bounds=%d,%d %dx%d" PRIu64 "\n", depth.c_str(), | 413 "%sid=%d,%d visible=%s bounds=%d,%d %dx%d %s\n", depth.c_str(), |
|
msw
2016/05/05 22:12:08
nit: maybe name='%s'?
James Cook
2016/05/05 22:53:18
Done.
| |
| 406 static_cast<int>(id_.connection_id), static_cast<int>(id_.window_id), | 414 static_cast<int>(id_.connection_id), static_cast<int>(id_.window_id), |
| 407 visible_ ? "true" : "false", bounds_.x(), bounds_.y(), bounds_.width(), | 415 visible_ ? "true" : "false", bounds_.x(), bounds_.y(), bounds_.width(), |
| 408 bounds_.height()); | 416 bounds_.height(), GetName().c_str()); |
| 409 for (const ServerWindow* child : children_) | 417 for (const ServerWindow* child : children_) |
| 410 child->BuildDebugInfo(depth + " ", result); | 418 child->BuildDebugInfo(depth + " ", result); |
| 411 } | 419 } |
| 412 #endif | 420 #endif |
| 413 | 421 |
| 414 void ServerWindow::RemoveImpl(ServerWindow* window) { | 422 void ServerWindow::RemoveImpl(ServerWindow* window) { |
| 415 window->parent_ = nullptr; | 423 window->parent_ = nullptr; |
| 416 children_.erase(std::find(children_.begin(), children_.end(), window)); | 424 children_.erase(std::find(children_.begin(), children_.end(), window)); |
| 417 } | 425 } |
| 418 | 426 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 459 } | 467 } |
| 460 | 468 |
| 461 // static | 469 // static |
| 462 ServerWindow** ServerWindow::GetStackingTarget(ServerWindow* window) { | 470 ServerWindow** ServerWindow::GetStackingTarget(ServerWindow* window) { |
| 463 return &window->stacking_target_; | 471 return &window->stacking_target_; |
| 464 } | 472 } |
| 465 | 473 |
| 466 } // namespace ws | 474 } // namespace ws |
| 467 | 475 |
| 468 } // namespace mus | 476 } // namespace mus |
| OLD | NEW |