Index: views/widget/native_widget_aura.cc |
diff --git a/views/widget/native_widget_aura.cc b/views/widget/native_widget_aura.cc |
index 53d4216970906dc3b2a5921d98f5885acdfa648b..2587f8596cd62615ffddd0bba00e2d6661e79730 100644 |
--- a/views/widget/native_widget_aura.cc |
+++ b/views/widget/native_widget_aura.cc |
@@ -144,6 +144,9 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { |
gfx::NativeView parent = params.GetParent(); |
if (parent) |
parent->AddTransientChild(window_); |
+ // SetAlwaysOnTop before SetParent so that always-on-top container is used. |
+ if (params.keep_on_top) |
+ SetAlwaysOnTop(true); |
window_->SetParent(NULL); |
} |
// TODO(beng): do this some other way. |
@@ -418,8 +421,32 @@ bool NativeWidgetAura::IsActive() const { |
} |
void NativeWidgetAura::SetAlwaysOnTop(bool on_top) { |
- // http://crbug.com/102582 |
- NOTIMPLEMENTED(); |
+ switch (window_->type()) { |
+ case aura::WINDOW_TYPE_NORMAL: |
+ case aura::WINDOW_TYPE_POPUP: |
+ SetNativeWindowProperty(aura::kAlwaysOnTopKey, |
+ reinterpret_cast<void*>(on_top)); |
+ |
+ // Having a parent means it's added to some container already. |
+ // Doing SetParent again here to make sure window_ is put in the right |
+ // container. |
+ // TODO(xiyuan): Optimize and only switch containers when necessary. |
+ if (window_->parent()) { |
+ window_->parent()->RemoveChild(window_); |
+ window_->SetParent(NULL); |
+ } |
+ |
+ break; |
+ case aura::WINDOW_TYPE_MENU: |
+ case aura::WINDOW_TYPE_TOOLTIP: |
+ // Menu and tooptip has their own container and ignores always-on-top. |
+ break; |
+ default: |
+ NOTREACHED() << "Window " << window_->id() |
+ << " of type " << window_->type() |
+ << " does not support always-on-top."; |
+ break; |
+ } |
} |
void NativeWidgetAura::Maximize() { |