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 "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
10 #include "ui/aura/client/drag_drop_client.h" | 10 #include "ui/aura/client/drag_drop_client.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 window_->SetType(GetAuraWindowTypeForWidgetType(window_type)); | 130 window_->SetType(GetAuraWindowTypeForWidgetType(window_type)); |
131 window_->SetIntProperty(aura::kShowStateKey, ui::SHOW_STATE_NORMAL); | 131 window_->SetIntProperty(aura::kShowStateKey, ui::SHOW_STATE_NORMAL); |
132 window_->Init(params.create_texture_for_layer ? | 132 window_->Init(params.create_texture_for_layer ? |
133 ui::Layer::LAYER_HAS_TEXTURE : | 133 ui::Layer::LAYER_HAS_TEXTURE : |
134 ui::Layer::LAYER_HAS_NO_TEXTURE); | 134 ui::Layer::LAYER_HAS_NO_TEXTURE); |
135 if (window_type == Widget::InitParams::TYPE_CONTROL) | 135 if (window_type == Widget::InitParams::TYPE_CONTROL) |
136 window_->Show(); | 136 window_->Show(); |
137 | 137 |
138 window_->layer()->SetFillsBoundsOpaquely(!params.transparent); | 138 window_->layer()->SetFillsBoundsOpaquely(!params.transparent); |
139 delegate_->OnNativeWidgetCreated(); | 139 delegate_->OnNativeWidgetCreated(); |
140 window_->set_minimum_size(delegate_->GetMinimumSize()); | |
141 window_->SetBounds(params.bounds); | 140 window_->SetBounds(params.bounds); |
142 if (window_type == Widget::InitParams::TYPE_CONTROL) { | 141 if (window_type == Widget::InitParams::TYPE_CONTROL) { |
143 window_->SetParent(params.GetParent()); | 142 window_->SetParent(params.GetParent()); |
144 } else { | 143 } else { |
145 // Set up the transient child before the window is added. This way the | 144 // Set up the transient child before the window is added. This way the |
146 // LayoutManager knows the window has a transient parent. | 145 // LayoutManager knows the window has a transient parent. |
147 gfx::NativeView parent = params.GetParent(); | 146 gfx::NativeView parent = params.GetParent(); |
148 if (parent) | 147 if (parent) |
149 parent->AddTransientChild(window_); | 148 parent->AddTransientChild(window_); |
150 // SetAlwaysOnTop before SetParent so that always-on-top container is used. | 149 // SetAlwaysOnTop before SetParent so that always-on-top container is used. |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { | 284 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { |
286 const gfx::Rect parent_bounds = window_->parent()->bounds(); | 285 const gfx::Rect parent_bounds = window_->parent()->bounds(); |
287 window_->SetBounds(gfx::Rect((parent_bounds.width() - size.width())/2, | 286 window_->SetBounds(gfx::Rect((parent_bounds.width() - size.width())/2, |
288 (parent_bounds.height() - size.height())/2, | 287 (parent_bounds.height() - size.height())/2, |
289 size.width(), | 288 size.width(), |
290 size.height())); | 289 size.height())); |
291 } | 290 } |
292 | 291 |
293 void NativeWidgetAura::GetWindowPlacement( | 292 void NativeWidgetAura::GetWindowPlacement( |
294 gfx::Rect* bounds, | 293 gfx::Rect* bounds, |
295 ui::WindowShowState* maximized) const { | 294 ui::WindowShowState* show_state) const { |
296 *maximized = static_cast<ui::WindowShowState>( | 295 *bounds = window_->GetTargetBounds(); |
| 296 *show_state = static_cast<ui::WindowShowState>( |
297 window_->GetIntProperty(aura::kShowStateKey)); | 297 window_->GetIntProperty(aura::kShowStateKey)); |
298 } | 298 } |
299 | 299 |
300 void NativeWidgetAura::SetWindowTitle(const string16& title) { | 300 void NativeWidgetAura::SetWindowTitle(const string16& title) { |
301 window_->set_title(title); | 301 window_->set_title(title); |
302 } | 302 } |
303 | 303 |
304 void NativeWidgetAura::SetWindowIcons(const SkBitmap& window_icon, | 304 void NativeWidgetAura::SetWindowIcons(const SkBitmap& window_icon, |
305 const SkBitmap& app_icon) { | 305 const SkBitmap& app_icon) { |
306 // Aura doesn't have window icons. | 306 // Aura doesn't have window icons. |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 void NativeWidgetAura::DispatchKeyEventPostIME(const KeyEvent& key) { | 536 void NativeWidgetAura::DispatchKeyEventPostIME(const KeyEvent& key) { |
537 if (delegate_->OnKeyEvent(key)) | 537 if (delegate_->OnKeyEvent(key)) |
538 return; | 538 return; |
539 if (key.type() == ui::ET_KEY_PRESSED && GetWidget()->GetFocusManager()) | 539 if (key.type() == ui::ET_KEY_PRESSED && GetWidget()->GetFocusManager()) |
540 GetWidget()->GetFocusManager()->OnKeyEvent(key); | 540 GetWidget()->GetFocusManager()->OnKeyEvent(key); |
541 } | 541 } |
542 | 542 |
543 //////////////////////////////////////////////////////////////////////////////// | 543 //////////////////////////////////////////////////////////////////////////////// |
544 // NativeWidgetAura, aura::WindowDelegate implementation: | 544 // NativeWidgetAura, aura::WindowDelegate implementation: |
545 | 545 |
| 546 void NativeWidgetAura::OnBoundsChanging(gfx::Rect* new_bounds) { |
| 547 // Enforces a minimum size. |
| 548 const gfx::Size& min_size = delegate_->GetMinimumSize(); |
| 549 new_bounds->set_width(std::max(min_size.width(), new_bounds->width())); |
| 550 new_bounds->set_height(std::max(min_size.height(), new_bounds->height())); |
| 551 } |
| 552 |
546 void NativeWidgetAura::OnBoundsChanged(const gfx::Rect& old_bounds, | 553 void NativeWidgetAura::OnBoundsChanged(const gfx::Rect& old_bounds, |
547 const gfx::Rect& new_bounds) { | 554 const gfx::Rect& new_bounds) { |
548 if (old_bounds.origin() != new_bounds.origin()) | 555 if (old_bounds.origin() != new_bounds.origin()) |
549 GetWidget()->widget_delegate()->OnWidgetMove(); | 556 GetWidget()->widget_delegate()->OnWidgetMove(); |
550 if (old_bounds.size() != new_bounds.size()) | 557 if (old_bounds.size() != new_bounds.size()) |
551 delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); | 558 delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); |
552 } | 559 } |
553 | 560 |
554 void NativeWidgetAura::OnFocus() { | 561 void NativeWidgetAura::OnFocus() { |
555 Widget* widget = GetWidget(); | 562 Widget* widget = GetWidget(); |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 NOTIMPLEMENTED(); | 784 NOTIMPLEMENTED(); |
778 } | 785 } |
779 | 786 |
780 // static | 787 // static |
781 bool NativeWidgetPrivate::IsMouseButtonDown() { | 788 bool NativeWidgetPrivate::IsMouseButtonDown() { |
782 return aura::Desktop::GetInstance()->IsMouseButtonDown(); | 789 return aura::Desktop::GetInstance()->IsMouseButtonDown(); |
783 } | 790 } |
784 | 791 |
785 } // namespace internal | 792 } // namespace internal |
786 } // namespace views | 793 } // namespace views |
OLD | NEW |