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

Unified Diff: ui/wm/core/transient_window_manager.cc

Issue 628413002: Show transient child when the transient parent is shown (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months 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/wm/core/transient_window_manager.h ('k') | ui/wm/core/transient_window_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/wm/core/transient_window_manager.cc
diff --git a/ui/wm/core/transient_window_manager.cc b/ui/wm/core/transient_window_manager.cc
index 120af84786c5b98a717491d7b4ff263d8facef53..9a2ba387911f95d030d51e8360b683e1b1545254 100644
--- a/ui/wm/core/transient_window_manager.cc
+++ b/ui/wm/core/transient_window_manager.cc
@@ -18,9 +18,12 @@
using aura::Window;
namespace wm {
+namespace {
DEFINE_OWNED_WINDOW_PROPERTY_KEY(TransientWindowManager, kPropertyKey, NULL);
+} // namespace
+
TransientWindowManager::~TransientWindowManager() {
}
@@ -97,7 +100,10 @@ bool TransientWindowManager::IsStackingTransient(
TransientWindowManager::TransientWindowManager(Window* window)
: window_(window),
transient_parent_(NULL),
- stacking_target_(NULL) {
+ stacking_target_(NULL),
+ parent_controls_visibility_(false),
+ show_on_parent_visible_(false),
+ ignore_visibility_changed_event_(false) {
window_->AddObserver(this);
}
@@ -134,18 +140,44 @@ void TransientWindowManager::OnWindowParentChanged(aura::Window* window,
}
}
+void TransientWindowManager::UpdateTransientChildVisibility(
+ bool parent_visible) {
+ base::AutoReset<bool> reset(&ignore_visibility_changed_event_, true);
+ if (!parent_visible) {
+ show_on_parent_visible_ = window_->TargetVisibility();
+ window_->Hide();
+ } else {
+ if (show_on_parent_visible_ && parent_controls_visibility_)
+ window_->Show();
+ show_on_parent_visible_ = false;
+ }
+}
+
void TransientWindowManager::OnWindowVisibilityChanging(Window* window,
bool visible) {
- // TODO(sky): move handling of becoming visible here.
- if (!visible) {
- std::for_each(transient_children_.begin(), transient_children_.end(),
- std::mem_fun(&Window::Hide));
+ DCHECK_EQ(window_, window);
+
+ for (auto* child : transient_children_)
+ Get(child)->UpdateTransientChildVisibility(visible);
+}
+
+void TransientWindowManager::OnWindowVisibilityChanged(Window* window,
+ bool visible) {
+ if (window_ != window || ignore_visibility_changed_event_ ||
+ !transient_parent_ || !parent_controls_visibility_) {
+ return;
+ }
+ if (!transient_parent_->TargetVisibility() && visible) {
+ base::AutoReset<bool> reset(&ignore_visibility_changed_event_, true);
+ show_on_parent_visible_ = true;
+ window_->Hide();
+ } else if (!visible) {
+ DCHECK(!show_on_parent_visible_);
}
}
void TransientWindowManager::OnWindowStackingChanged(Window* window) {
DCHECK_EQ(window_, window);
-
// Do nothing if we initiated the stacking change.
const TransientWindowManager* transient_manager =
Get(static_cast<const Window*>(window));
« no previous file with comments | « ui/wm/core/transient_window_manager.h ('k') | ui/wm/core/transient_window_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698