OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/views/widget/native_widget_aura.h" | 5 #include "ui/views/widget/native_widget_aura.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "third_party/skia/include/core/SkRegion.h" | 9 #include "third_party/skia/include/core/SkRegion.h" |
10 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 if (parent && window_bounds == gfx::Rect()) { | 136 if (parent && window_bounds == gfx::Rect()) { |
137 // If a parent is specified but no bounds are given, | 137 // If a parent is specified but no bounds are given, |
138 // use the origin of the parent's display so that the widget | 138 // use the origin of the parent's display so that the widget |
139 // will be added to the same display as the parent. | 139 // will be added to the same display as the parent. |
140 gfx::Rect bounds = gfx::Screen::GetScreenFor(parent)-> | 140 gfx::Rect bounds = gfx::Screen::GetScreenFor(parent)-> |
141 GetDisplayNearestWindow(parent).bounds(); | 141 GetDisplayNearestWindow(parent).bounds(); |
142 window_bounds.set_origin(bounds.origin()); | 142 window_bounds.set_origin(bounds.origin()); |
143 } | 143 } |
144 } | 144 } |
145 | 145 |
146 // Set properties before addeing to the parent so that its layout manager | 146 // Set properties before adding to the parent so that its layout manager sees |
147 // sees the correct values. | 147 // the correct values. |
148 window_->SetProperty(aura::client::kCanMaximizeKey, | 148 OnSizeConstraintsChanged(); |
149 GetWidget()->widget_delegate()->CanMaximize()); | |
150 window_->SetProperty(aura::client::kCanResizeKey, | |
151 GetWidget()->widget_delegate()->CanResize()); | |
152 | 149 |
153 if (parent) { | 150 if (parent) { |
154 parent->AddChild(window_); | 151 parent->AddChild(window_); |
155 } else { | 152 } else { |
156 aura::client::ParentWindowWithContext( | 153 aura::client::ParentWindowWithContext( |
157 window_, context->GetRootWindow(), window_bounds); | 154 window_, context->GetRootWindow(), window_bounds); |
158 } | 155 } |
159 | 156 |
160 // Start observing property changes. | 157 // Start observing property changes. |
161 window_->AddObserver(this); | 158 window_->AddObserver(this); |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 #endif | 690 #endif |
694 } | 691 } |
695 | 692 |
696 void NativeWidgetAura::OnRootViewLayout() { | 693 void NativeWidgetAura::OnRootViewLayout() { |
697 } | 694 } |
698 | 695 |
699 bool NativeWidgetAura::IsTranslucentWindowOpacitySupported() const { | 696 bool NativeWidgetAura::IsTranslucentWindowOpacitySupported() const { |
700 return true; | 697 return true; |
701 } | 698 } |
702 | 699 |
| 700 void NativeWidgetAura::OnSizeConstraintsChanged() { |
| 701 window_->SetProperty(aura::client::kCanMaximizeKey, |
| 702 GetWidget()->widget_delegate()->CanMaximize()); |
| 703 window_->SetProperty(aura::client::kCanResizeKey, |
| 704 GetWidget()->widget_delegate()->CanResize()); |
| 705 } |
| 706 |
703 void NativeWidgetAura::RepostNativeEvent(gfx::NativeEvent native_event) { | 707 void NativeWidgetAura::RepostNativeEvent(gfx::NativeEvent native_event) { |
704 OnEvent(native_event); | 708 OnEvent(native_event); |
705 } | 709 } |
706 | 710 |
707 //////////////////////////////////////////////////////////////////////////////// | 711 //////////////////////////////////////////////////////////////////////////////// |
708 // NativeWidgetAura, views::InputMethodDelegate implementation: | 712 // NativeWidgetAura, views::InputMethodDelegate implementation: |
709 | 713 |
710 void NativeWidgetAura::DispatchKeyEventPostIME(const ui::KeyEvent& key) { | 714 void NativeWidgetAura::DispatchKeyEventPostIME(const ui::KeyEvent& key) { |
711 FocusManager* focus_manager = GetWidget()->GetFocusManager(); | 715 FocusManager* focus_manager = GetWidget()->GetFocusManager(); |
712 delegate_->OnKeyEvent(const_cast<ui::KeyEvent*>(&key)); | 716 delegate_->OnKeyEvent(const_cast<ui::KeyEvent*>(&key)); |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1168 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); | 1172 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); |
1169 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); | 1173 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); |
1170 return gfx::FontList(gfx::Font(caption_font)); | 1174 return gfx::FontList(gfx::Font(caption_font)); |
1171 #else | 1175 #else |
1172 return gfx::FontList(); | 1176 return gfx::FontList(); |
1173 #endif | 1177 #endif |
1174 } | 1178 } |
1175 | 1179 |
1176 } // namespace internal | 1180 } // namespace internal |
1177 } // namespace views | 1181 } // namespace views |
OLD | NEW |