Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: views/widget/native_widget_views.cc

Issue 8524020: Fix sad tab in native_widget_views (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/widget/native_widget_views.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_views.h" 5 #include "views/widget/native_widget_views.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "ui/base/hit_test.h" 8 #include "ui/base/hit_test.h"
9 #include "ui/gfx/compositor/compositor.h" 9 #include "ui/gfx/compositor/compositor.h"
10 #include "ui/gfx/compositor/layer.h" 10 #include "ui/gfx/compositor/layer.h"
(...skipping 27 matching lines...) Expand all
38 } // namespace 38 } // namespace
39 39
40 namespace views { 40 namespace views {
41 41
42 //////////////////////////////////////////////////////////////////////////////// 42 ////////////////////////////////////////////////////////////////////////////////
43 // NativeWidgetViews, public: 43 // NativeWidgetViews, public:
44 44
45 NativeWidgetViews::NativeWidgetViews(internal::NativeWidgetDelegate* delegate) 45 NativeWidgetViews::NativeWidgetViews(internal::NativeWidgetDelegate* delegate)
46 : delegate_(delegate), 46 : delegate_(delegate),
47 parent_(NULL), 47 parent_(NULL),
48 bounds_relative_to_parent_(false),
48 view_(NULL), 49 view_(NULL),
49 active_(false), 50 active_(false),
50 window_state_(ui::SHOW_STATE_DEFAULT), 51 window_state_(ui::SHOW_STATE_DEFAULT),
51 always_on_top_(false), 52 always_on_top_(false),
52 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), 53 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)),
53 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), 54 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET),
54 delete_native_view_(true) { 55 delete_native_view_(true) {
55 } 56 }
56 57
57 NativeWidgetViews::~NativeWidgetViews() { 58 NativeWidgetViews::~NativeWidgetViews() {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 return HandleWindowOperation(event) ? true : delegate_->OnMouseEvent(event); 135 return HandleWindowOperation(event) ? true : delegate_->OnMouseEvent(event);
135 } 136 }
136 137
137 //////////////////////////////////////////////////////////////////////////////// 138 ////////////////////////////////////////////////////////////////////////////////
138 // NativeWidgetViews, NativeWidget implementation: 139 // NativeWidgetViews, NativeWidget implementation:
139 140
140 void NativeWidgetViews::InitNativeWidget(const Widget::InitParams& params) { 141 void NativeWidgetViews::InitNativeWidget(const Widget::InitParams& params) {
141 parent_ = params.parent_widget; 142 parent_ = params.parent_widget;
142 ownership_ = params.ownership; 143 ownership_ = params.ownership;
143 always_on_top_ = params.keep_on_top; 144 always_on_top_ = params.keep_on_top;
145 bounds_relative_to_parent_ =
146 (params.type == Widget::InitParams::TYPE_CONTROL);
144 View* parent_view = NULL; 147 View* parent_view = NULL;
145 if (params.parent_widget) { 148 if (params.parent_widget) {
146 parent_view = params.parent_widget->GetChildViewParent(); 149 parent_view = params.parent_widget->GetChildViewParent();
147 } else if (ViewsDelegate::views_delegate && 150 } else if (ViewsDelegate::views_delegate &&
148 ViewsDelegate::views_delegate->GetDefaultParentView() && 151 ViewsDelegate::views_delegate->GetDefaultParentView() &&
149 !params.child) { 152 !params.child) {
150 parent_view = ViewsDelegate::views_delegate->GetDefaultParentView(); 153 parent_view = ViewsDelegate::views_delegate->GetDefaultParentView();
151 } else if (params.parent) { 154 } else if (params.parent) {
152 Widget* widget = Widget::GetWidgetForNativeView(params.parent); 155 Widget* widget = Widget::GetWidgetForNativeView(params.parent);
153 parent_view = widget->GetChildViewParent(); 156 parent_view = widget->GetChildViewParent();
154 } 157 }
155 158
156 gfx::Rect bounds = AdjustRectOriginForParentWidget(params.bounds, 159 gfx::Rect bounds = bounds_relative_to_parent_ ?
157 parent_); 160 params.bounds : AdjustRectOriginForParentWidget(params.bounds, parent_);
158 view_ = new internal::NativeWidgetView(this); 161 view_ = new internal::NativeWidgetView(this);
159 view_->SetBoundsRect(bounds); 162 view_->SetBoundsRect(bounds);
160 view_->SetVisible(params.type == Widget::InitParams::TYPE_CONTROL); 163 view_->SetVisible(params.type == Widget::InitParams::TYPE_CONTROL);
161 164
162 // With the default NATIVE_WIDGET_OWNS_WIDGET ownership, the 165 // With the default NATIVE_WIDGET_OWNS_WIDGET ownership, the
163 // deletion of either of the NativeWidgetViews or NativeWidgetView 166 // deletion of either of the NativeWidgetViews or NativeWidgetView
164 // (e.g. via View hierarchy destruction) will delete the other. 167 // (e.g. via View hierarchy destruction) will delete the other.
165 // With WIDGET_OWNS_NATIVE_WIDGET, NativeWidgetViews should only 168 // With WIDGET_OWNS_NATIVE_WIDGET, NativeWidgetViews should only
166 // be deleted by its Widget. 169 // be deleted by its Widget.
167 if (ownership_ == Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET) 170 if (ownership_ == Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET)
168 view_->set_delete_native_widget(false); 171 view_->set_delete_native_widget(false);
169
170 if (parent_view) 172 if (parent_view)
171 parent_view->AddChildView(view_); 173 parent_view->AddChildView(view_);
172 view_->SetPaintToLayer(true); 174 view_->SetPaintToLayer(true);
173 if (View::get_use_acceleration_when_possible()) 175 if (View::get_use_acceleration_when_possible())
174 view_->SetFillsBoundsOpaquely(!params.transparent); 176 view_->SetFillsBoundsOpaquely(!params.transparent);
175 // TODO(beng): SetInitParams(). 177 // TODO(beng): SetInitParams().
176 } 178 }
177 179
178 NonClientFrameView* NativeWidgetViews::CreateNonClientFrameView() { 180 NonClientFrameView* NativeWidgetViews::CreateNonClientFrameView() {
179 return NULL; 181 return NULL;
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 346
345 gfx::Rect NativeWidgetViews::GetClientAreaScreenBounds() const { 347 gfx::Rect NativeWidgetViews::GetClientAreaScreenBounds() const {
346 return GetWindowScreenBounds(); 348 return GetWindowScreenBounds();
347 } 349 }
348 350
349 gfx::Rect NativeWidgetViews::GetRestoredBounds() const { 351 gfx::Rect NativeWidgetViews::GetRestoredBounds() const {
350 return GetWindowScreenBounds(); 352 return GetWindowScreenBounds();
351 } 353 }
352 354
353 void NativeWidgetViews::SetBounds(const gfx::Rect& bounds) { 355 void NativeWidgetViews::SetBounds(const gfx::Rect& bounds) {
354 // |bounds| are supplied in the coordinates of the parent. 356 // |bounds| are supplied in the coordinates of the parent.
sadrul 2011/11/14 17:23:04 Update the comment here explaining that for toplev
355 view_->SetBoundsRect(AdjustRectOriginForParentWidget(bounds, parent_)); 357 if (bounds_relative_to_parent_)
358 view_->SetBoundsRect(bounds);
sadrul 2011/11/14 17:23:04 Is it sufficient to just check for !GetWidget()->i
359 else
360 view_->SetBoundsRect(AdjustRectOriginForParentWidget(bounds, parent_));
356 } 361 }
357 362
358 void NativeWidgetViews::SetSize(const gfx::Size& size) { 363 void NativeWidgetViews::SetSize(const gfx::Size& size) {
359 view_->SetSize(size); 364 view_->SetSize(size);
360 } 365 }
361 366
362 void NativeWidgetViews::MoveAbove(gfx::NativeView native_view) { 367 void NativeWidgetViews::MoveAbove(gfx::NativeView native_view) {
363 NOTIMPLEMENTED(); 368 NOTIMPLEMENTED();
364 } 369 }
365 370
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 } 641 }
637 default: 642 default:
638 // Everything else falls into standard client event handling. 643 // Everything else falls into standard client event handling.
639 break; 644 break;
640 } 645 }
641 } 646 }
642 return false; 647 return false;
643 } 648 }
644 649
645 } // namespace views 650 } // namespace views
OLDNEW
« no previous file with comments | « views/widget/native_widget_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698