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/widget.h" | 5 #include "ui/views/widget/widget.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "ui/base/events/event.h" | 10 #include "ui/base/events/event.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 internal::NativeWidgetDelegate* delegate, | 56 internal::NativeWidgetDelegate* delegate, |
57 Widget::InitParams::Type type, | 57 Widget::InitParams::Type type, |
58 gfx::NativeView parent) { | 58 gfx::NativeView parent) { |
59 if (!native_widget) { | 59 if (!native_widget) { |
60 if (ViewsDelegate::views_delegate) { | 60 if (ViewsDelegate::views_delegate) { |
61 native_widget = ViewsDelegate::views_delegate->CreateNativeWidget( | 61 native_widget = ViewsDelegate::views_delegate->CreateNativeWidget( |
62 type, delegate, parent); | 62 type, delegate, parent); |
63 } | 63 } |
64 if (!native_widget) { | 64 if (!native_widget) { |
65 native_widget = | 65 native_widget = |
66 internal::NativeWidgetPrivate::CreateNativeWidget(delegate); | 66 internal::NativeWidgetPrivate::CreateNativeWidget(delegate, parent); |
67 } | 67 } |
68 } | 68 } |
69 return native_widget; | 69 return native_widget; |
70 } | 70 } |
71 | 71 |
72 } // namespace | 72 } // namespace |
73 | 73 |
74 // This class is used to keep track of the event a Widget is processing, and | 74 // This class is used to keep track of the event a Widget is processing, and |
75 // restore any previously active event afterwards. | 75 // restore any previously active event afterwards. |
76 class ScopedEvent { | 76 class ScopedEvent { |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 void Widget::SetSize(const gfx::Size& size) { | 460 void Widget::SetSize(const gfx::Size& size) { |
461 native_widget_->SetSize(size); | 461 native_widget_->SetSize(size); |
462 } | 462 } |
463 | 463 |
464 void Widget::CenterWindow(const gfx::Size& size) { | 464 void Widget::CenterWindow(const gfx::Size& size) { |
465 native_widget_->CenterWindow(size); | 465 native_widget_->CenterWindow(size); |
466 } | 466 } |
467 | 467 |
468 void Widget::SetBoundsConstrained(const gfx::Rect& bounds) { | 468 void Widget::SetBoundsConstrained(const gfx::Rect& bounds) { |
469 gfx::Rect work_area = | 469 gfx::Rect work_area = |
470 gfx::Screen::GetDisplayNearestPoint(bounds.origin()).work_area(); | 470 gfx::Screen::GetScreenFor(GetNativeView())->GetDisplayNearestPoint( |
| 471 bounds.origin()).work_area(); |
471 if (work_area.IsEmpty()) { | 472 if (work_area.IsEmpty()) { |
472 SetBounds(bounds); | 473 SetBounds(bounds); |
473 } else { | 474 } else { |
474 // Inset the work area slightly. | 475 // Inset the work area slightly. |
475 work_area.Inset(10, 10, 10, 10); | 476 work_area.Inset(10, 10, 10, 10); |
476 SetBounds(work_area.AdjustToFit(bounds)); | 477 SetBounds(work_area.AdjustToFit(bounds)); |
477 } | 478 } |
478 } | 479 } |
479 | 480 |
480 void Widget::SetVisibilityChangedAnimationsEnabled(bool value) { | 481 void Widget::SetVisibilityChangedAnimationsEnabled(bool value) { |
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1348 | 1349 |
1349 //////////////////////////////////////////////////////////////////////////////// | 1350 //////////////////////////////////////////////////////////////////////////////// |
1350 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1351 // internal::NativeWidgetPrivate, NativeWidget implementation: |
1351 | 1352 |
1352 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1353 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
1353 return this; | 1354 return this; |
1354 } | 1355 } |
1355 | 1356 |
1356 } // namespace internal | 1357 } // namespace internal |
1357 } // namespace views | 1358 } // namespace views |
OLD | NEW |