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

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

Issue 8194004: change the way windows are parented when their parent is set to NULL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months 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/views.gyp ('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_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/desktop.h" 8 #include "ui/aura/desktop.h"
9 #include "ui/aura/event.h" 9 #include "ui/aura/event.h"
10 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
11 #include "ui/aura/window_types.h"
11 #include "ui/base/ui_base_types.h" 12 #include "ui/base/ui_base_types.h"
12 #include "ui/gfx/canvas.h" 13 #include "ui/gfx/canvas.h"
13 #include "ui/gfx/compositor/layer.h" 14 #include "ui/gfx/compositor/layer.h"
14 #include "ui/gfx/font.h" 15 #include "ui/gfx/font.h"
15 #include "ui/gfx/screen.h" 16 #include "ui/gfx/screen.h"
16 #include "views/widget/native_widget_delegate.h" 17 #include "views/widget/native_widget_delegate.h"
17 18
18 #if defined(OS_WIN) 19 #if defined(OS_WIN)
19 #include "base/win/scoped_gdi_object.h" 20 #include "base/win/scoped_gdi_object.h"
20 #include "base/win/win_util.h" 21 #include "base/win/win_util.h"
21 #include "ui/base/l10n/l10n_util_win.h" 22 #include "ui/base/l10n/l10n_util_win.h"
22 #endif 23 #endif
23 24
24 #if defined(HAVE_IBUS) 25 #if defined(HAVE_IBUS)
25 #include "views/ime/input_method_ibus.h" 26 #include "views/ime/input_method_ibus.h"
26 #else 27 #else
27 #include "views/ime/mock_input_method.h" 28 #include "views/ime/mock_input_method.h"
28 #endif 29 #endif
29 30
30 namespace views { 31 namespace views {
31 32
33 namespace {
34
35 int GetAuraWindowTypeForWidgetType(Widget::InitParams::Type type) {
36 switch (type) {
37 case Widget::InitParams::TYPE_WINDOW:
38 case Widget::InitParams::TYPE_WINDOW_FRAMELESS:
39 case Widget::InitParams::TYPE_POPUP:
40 case Widget::InitParams::TYPE_BUBBLE:
41 return aura::kWindowType_Toplevel;
42 case Widget::InitParams::TYPE_CONTROL:
43 return aura::kWindowType_Control;
44 case Widget::InitParams::TYPE_MENU:
45 return aura::kWindowType_Menu;
46 case Widget::InitParams::TYPE_TOOLTIP:
47 return aura::kWindowType_Tooltip;
48 default:
49 NOTREACHED();
50 break;
51 }
52 return aura::kWindowType_Toplevel;
53 }
54
55 } // namespace
56
32 //////////////////////////////////////////////////////////////////////////////// 57 ////////////////////////////////////////////////////////////////////////////////
33 // NativeWidgetAura, public: 58 // NativeWidgetAura, public:
34 59
35 NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) 60 NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate)
36 : delegate_(delegate), 61 : delegate_(delegate),
37 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), 62 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))),
38 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), 63 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET),
39 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), 64 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)),
40 can_activate_(true), 65 can_activate_(true),
41 cursor_(NULL) { 66 cursor_(NULL) {
(...skipping 18 matching lines...) Expand all
60 return gfx::Font(); 85 return gfx::Font();
61 #endif 86 #endif
62 } 87 }
63 88
64 //////////////////////////////////////////////////////////////////////////////// 89 ////////////////////////////////////////////////////////////////////////////////
65 // NativeWidgetAura, internal::NativeWidgetPrivate implementation: 90 // NativeWidgetAura, internal::NativeWidgetPrivate implementation:
66 91
67 void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { 92 void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) {
68 ownership_ = params.ownership; 93 ownership_ = params.ownership;
69 window_->set_user_data(this); 94 window_->set_user_data(this);
95 window_->SetType(GetAuraWindowTypeForWidgetType(params.type));
70 window_->Init(); 96 window_->Init();
71 // TODO(beng): respect |params| authoritah wrt transparency. 97 // TODO(beng): respect |params| authoritah wrt transparency.
72 window_->layer()->SetFillsBoundsOpaquely(false); 98 window_->layer()->SetFillsBoundsOpaquely(false);
73 delegate_->OnNativeWidgetCreated(); 99 delegate_->OnNativeWidgetCreated();
74 window_->SetBounds(params.bounds); 100 window_->SetBounds(params.bounds);
75 window_->SetParent(params.parent); 101 window_->SetParent(
102 params.type == Widget::InitParams::TYPE_MENU ? NULL : params.parent);
76 // TODO(beng): do this some other way. 103 // TODO(beng): do this some other way.
77 delegate_->OnNativeWidgetSizeChanged(params.bounds.size()); 104 delegate_->OnNativeWidgetSizeChanged(params.bounds.size());
78 can_activate_ = params.can_activate; 105 can_activate_ = params.can_activate;
79 } 106 }
80 107
81 NonClientFrameView* NativeWidgetAura::CreateNonClientFrameView() { 108 NonClientFrameView* NativeWidgetAura::CreateNonClientFrameView() {
82 NOTIMPLEMENTED(); 109 NOTIMPLEMENTED();
83 return NULL; 110 return NULL;
84 } 111 }
85 112
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 } 567 }
541 568
542 // static 569 // static
543 NativeWidgetPrivate* NativeWidgetPrivate::GetTopLevelNativeWidget( 570 NativeWidgetPrivate* NativeWidgetPrivate::GetTopLevelNativeWidget(
544 gfx::NativeView native_view) { 571 gfx::NativeView native_view) {
545 if (!native_view) 572 if (!native_view)
546 return NULL; 573 return NULL;
547 aura::Window* toplevel = native_view; 574 aura::Window* toplevel = native_view;
548 aura::Window* parent = native_view->parent(); 575 aura::Window* parent = native_view->parent();
549 while (parent) { 576 while (parent) {
550 if (parent->IsToplevelWindowContainer()) 577 if (parent->AsToplevelWindowContainer())
551 return GetNativeWidgetForNativeView(toplevel); 578 return GetNativeWidgetForNativeView(toplevel);
552 toplevel = parent; 579 toplevel = parent;
553 parent = parent->parent(); 580 parent = parent->parent();
554 } 581 }
555 return NULL; 582 return NULL;
556 } 583 }
557 584
558 // static 585 // static
559 void NativeWidgetPrivate::GetAllChildWidgets(gfx::NativeView native_view, 586 void NativeWidgetPrivate::GetAllChildWidgets(gfx::NativeView native_view,
560 Widget::Widgets* children) { 587 Widget::Widgets* children) {
(...skipping 22 matching lines...) Expand all
583 } 610 }
584 611
585 // static 612 // static
586 bool NativeWidgetPrivate::IsMouseButtonDown() { 613 bool NativeWidgetPrivate::IsMouseButtonDown() {
587 NOTIMPLEMENTED(); 614 NOTIMPLEMENTED();
588 return false; 615 return false;
589 } 616 }
590 617
591 } // namespace internal 618 } // namespace internal
592 } // namespace views 619 } // namespace views
OLDNEW
« no previous file with comments | « views/views.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698