| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/widget/native_widget_aura.h" | 5 #include "views/widget/native_widget_aura.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "ui/aura/aura_constants.h" | 8 #include "ui/aura/aura_constants.h" |
| 9 #include "ui/aura/desktop.h" | 9 #include "ui/aura/desktop.h" |
| 10 #include "ui/aura/desktop_observer.h" | 10 #include "ui/aura/desktop_observer.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 window_->set_minimum_size(delegate_->GetMinimumSize()); | 137 window_->set_minimum_size(delegate_->GetMinimumSize()); |
| 138 window_->SetBounds(params.bounds); | 138 window_->SetBounds(params.bounds); |
| 139 if (params.type == Widget::InitParams::TYPE_CONTROL) { | 139 if (params.type == Widget::InitParams::TYPE_CONTROL) { |
| 140 window_->SetParent(params.GetParent()); | 140 window_->SetParent(params.GetParent()); |
| 141 } else { | 141 } else { |
| 142 // Set up the transient child before the window is added. This way the | 142 // Set up the transient child before the window is added. This way the |
| 143 // LayoutManager knows the window has a transient parent. | 143 // LayoutManager knows the window has a transient parent. |
| 144 gfx::NativeView parent = params.GetParent(); | 144 gfx::NativeView parent = params.GetParent(); |
| 145 if (parent) | 145 if (parent) |
| 146 parent->AddTransientChild(window_); | 146 parent->AddTransientChild(window_); |
| 147 // SetAlwaysOnTop before SetParent so that always-on-top container is used. |
| 148 if (params.keep_on_top) |
| 149 SetAlwaysOnTop(true); |
| 147 window_->SetParent(NULL); | 150 window_->SetParent(NULL); |
| 148 } | 151 } |
| 149 // TODO(beng): do this some other way. | 152 // TODO(beng): do this some other way. |
| 150 delegate_->OnNativeWidgetSizeChanged(params.bounds.size()); | 153 delegate_->OnNativeWidgetSizeChanged(params.bounds.size()); |
| 151 can_activate_ = params.can_activate; | 154 can_activate_ = params.can_activate; |
| 152 if (params.type != Widget::InitParams::TYPE_TOOLTIP && !params.child) { | 155 if (params.type != Widget::InitParams::TYPE_TOOLTIP && !params.child) { |
| 153 DCHECK(GetWidget()->GetRootView()); | 156 DCHECK(GetWidget()->GetRootView()); |
| 154 views::TooltipManagerViews* manager = new views::TooltipManagerViews( | 157 views::TooltipManagerViews* manager = new views::TooltipManagerViews( |
| 155 GetWidget()->GetRootView()); | 158 GetWidget()->GetRootView()); |
| 156 tooltip_manager_.reset(manager); | 159 tooltip_manager_.reset(manager); |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 | 414 |
| 412 void NativeWidgetAura::Deactivate() { | 415 void NativeWidgetAura::Deactivate() { |
| 413 window_->Deactivate(); | 416 window_->Deactivate(); |
| 414 } | 417 } |
| 415 | 418 |
| 416 bool NativeWidgetAura::IsActive() const { | 419 bool NativeWidgetAura::IsActive() const { |
| 417 return aura::Desktop::GetInstance()->active_window() == window_; | 420 return aura::Desktop::GetInstance()->active_window() == window_; |
| 418 } | 421 } |
| 419 | 422 |
| 420 void NativeWidgetAura::SetAlwaysOnTop(bool on_top) { | 423 void NativeWidgetAura::SetAlwaysOnTop(bool on_top) { |
| 421 // http://crbug.com/102582 | 424 switch (window_->type()) { |
| 422 NOTIMPLEMENTED(); | 425 case aura::WINDOW_TYPE_NORMAL: |
| 426 case aura::WINDOW_TYPE_POPUP: |
| 427 SetNativeWindowProperty(aura::kAlwaysOnTopKey, |
| 428 reinterpret_cast<void*>(on_top)); |
| 429 |
| 430 // Having a parent means it's added to some container already. |
| 431 // Doing SetParent again here to make sure window_ is put in the right |
| 432 // container. |
| 433 // TODO(xiyuan): Optimize and only switch containers when necessary. |
| 434 if (window_->parent()) { |
| 435 window_->parent()->RemoveChild(window_); |
| 436 window_->SetParent(NULL); |
| 437 } |
| 438 |
| 439 break; |
| 440 case aura::WINDOW_TYPE_MENU: |
| 441 case aura::WINDOW_TYPE_TOOLTIP: |
| 442 // Menu and tooptip has their own container and ignores always-on-top. |
| 443 break; |
| 444 default: |
| 445 NOTREACHED() << "Window " << window_->id() |
| 446 << " of type " << window_->type() |
| 447 << " does not support always-on-top."; |
| 448 break; |
| 449 } |
| 423 } | 450 } |
| 424 | 451 |
| 425 void NativeWidgetAura::Maximize() { | 452 void NativeWidgetAura::Maximize() { |
| 426 window_->SetIntProperty(aura::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 453 window_->SetIntProperty(aura::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 427 } | 454 } |
| 428 | 455 |
| 429 void NativeWidgetAura::Minimize() { | 456 void NativeWidgetAura::Minimize() { |
| 430 NOTREACHED(); | 457 NOTREACHED(); |
| 431 } | 458 } |
| 432 | 459 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 | 758 |
| 732 // static | 759 // static |
| 733 bool NativeWidgetPrivate::IsMouseButtonDown() { | 760 bool NativeWidgetPrivate::IsMouseButtonDown() { |
| 734 // http://crbug.com/102577 | 761 // http://crbug.com/102577 |
| 735 NOTIMPLEMENTED(); | 762 NOTIMPLEMENTED(); |
| 736 return false; | 763 return false; |
| 737 } | 764 } |
| 738 | 765 |
| 739 } // namespace internal | 766 } // namespace internal |
| 740 } // namespace views | 767 } // namespace views |
| OLD | NEW |