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

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

Issue 297503003: Revert: [Refactor] Consolidate the logic for whether a widget can be activated. This is a first ste (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | « ui/views/widget/native_widget_aura.h ('k') | ui/views/widget/native_widget_aura_unittest.cc » ('j') | 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) 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } // namespace 69 } // namespace
70 70
71 //////////////////////////////////////////////////////////////////////////////// 71 ////////////////////////////////////////////////////////////////////////////////
72 // NativeWidgetAura, public: 72 // NativeWidgetAura, public:
73 73
74 NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) 74 NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate)
75 : delegate_(delegate), 75 : delegate_(delegate),
76 window_(new aura::Window(this)), 76 window_(new aura::Window(this)),
77 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), 77 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET),
78 close_widget_factory_(this), 78 close_widget_factory_(this),
79 can_activate_(true),
79 destroying_(false), 80 destroying_(false),
80 cursor_(gfx::kNullCursor), 81 cursor_(gfx::kNullCursor),
81 saved_window_state_(ui::SHOW_STATE_DEFAULT) { 82 saved_window_state_(ui::SHOW_STATE_DEFAULT) {
82 aura::client::SetFocusChangeObserver(window_, this); 83 aura::client::SetFocusChangeObserver(window_, this);
83 aura::client::SetActivationChangeObserver(window_, this); 84 aura::client::SetActivationChangeObserver(window_, this);
84 } 85 }
85 86
86 // static 87 // static
87 void NativeWidgetAura::RegisterNativeWidgetForWindow( 88 void NativeWidgetAura::RegisterNativeWidgetForWindow(
88 internal::NativeWidgetPrivate* native_widget, 89 internal::NativeWidgetPrivate* native_widget,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } 154 }
154 155
155 // Wait to set the bounds until we have a parent. That way we can know our 156 // Wait to set the bounds until we have a parent. That way we can know our
156 // true state/bounds (the LayoutManager may enforce a particular 157 // true state/bounds (the LayoutManager may enforce a particular
157 // state/bounds). 158 // state/bounds).
158 if (IsMaximized()) 159 if (IsMaximized())
159 SetRestoreBounds(window_, window_bounds); 160 SetRestoreBounds(window_, window_bounds);
160 else 161 else
161 SetBounds(window_bounds); 162 SetBounds(window_bounds);
162 window_->set_ignore_events(!params.accept_events); 163 window_->set_ignore_events(!params.accept_events);
164 can_activate_ = params.can_activate &&
165 params.type != Widget::InitParams::TYPE_CONTROL &&
166 params.type != Widget::InitParams::TYPE_TOOLTIP;
163 DCHECK(GetWidget()->GetRootView()); 167 DCHECK(GetWidget()->GetRootView());
164 if (params.type != Widget::InitParams::TYPE_TOOLTIP) 168 if (params.type != Widget::InitParams::TYPE_TOOLTIP)
165 tooltip_manager_.reset(new views::TooltipManagerAura(GetWidget())); 169 tooltip_manager_.reset(new views::TooltipManagerAura(GetWidget()));
166 170
167 drop_helper_.reset(new DropHelper(GetWidget()->GetRootView())); 171 drop_helper_.reset(new DropHelper(GetWidget()->GetRootView()));
168 if (params.type != Widget::InitParams::TYPE_TOOLTIP && 172 if (params.type != Widget::InitParams::TYPE_TOOLTIP &&
169 params.type != Widget::InitParams::TYPE_POPUP) { 173 params.type != Widget::InitParams::TYPE_POPUP) {
170 aura::client::SetDragDropDelegate(window_, this); 174 aura::client::SetDragDropDelegate(window_, this);
171 } 175 }
172 176
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 ShowWithWindowState(ui::SHOW_STATE_MAXIMIZED); 480 ShowWithWindowState(ui::SHOW_STATE_MAXIMIZED);
477 } 481 }
478 482
479 void NativeWidgetAura::ShowWithWindowState(ui::WindowShowState state) { 483 void NativeWidgetAura::ShowWithWindowState(ui::WindowShowState state) {
480 if (!window_) 484 if (!window_)
481 return; 485 return;
482 486
483 if (state == ui::SHOW_STATE_MAXIMIZED || state == ui::SHOW_STATE_FULLSCREEN) 487 if (state == ui::SHOW_STATE_MAXIMIZED || state == ui::SHOW_STATE_FULLSCREEN)
484 window_->SetProperty(aura::client::kShowStateKey, state); 488 window_->SetProperty(aura::client::kShowStateKey, state);
485 window_->Show(); 489 window_->Show();
486 if (delegate_->CanActivate()) { 490 if (can_activate_) {
487 if (state != ui::SHOW_STATE_INACTIVE) 491 if (state != ui::SHOW_STATE_INACTIVE)
488 Activate(); 492 Activate();
489 // SetInitialFocus() should be always be called, even for 493 // SetInitialFocus() should be always be called, even for
490 // SHOW_STATE_INACTIVE. If the window has to stay inactive, the method will 494 // SHOW_STATE_INACTIVE. If the window has to stay inactive, the method will
491 // do the right thing. 495 // do the right thing.
492 SetInitialFocus(state); 496 SetInitialFocus(state);
493 } 497 }
494 } 498 }
495 499
496 bool NativeWidgetAura::IsVisible() const { 500 bool NativeWidgetAura::IsVisible() const {
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 std::find(window_->layer()->children().begin(), 766 std::find(window_->layer()->children().begin(),
763 window_->layer()->children().end(), layer)); 767 window_->layer()->children().end(), layer));
764 if (root_layer_iter > child_layer_iter) 768 if (root_layer_iter > child_layer_iter)
765 return false; 769 return false;
766 } 770 }
767 } 771 }
768 return true; 772 return true;
769 } 773 }
770 774
771 bool NativeWidgetAura::CanFocus() { 775 bool NativeWidgetAura::CanFocus() {
772 return ShouldActivate(); 776 return can_activate_;
773 } 777 }
774 778
775 void NativeWidgetAura::OnCaptureLost() { 779 void NativeWidgetAura::OnCaptureLost() {
776 delegate_->OnMouseCaptureLost(); 780 delegate_->OnMouseCaptureLost();
777 } 781 }
778 782
779 void NativeWidgetAura::OnPaint(gfx::Canvas* canvas) { 783 void NativeWidgetAura::OnPaint(gfx::Canvas* canvas) {
780 delegate_->OnNativeWidgetPaint(canvas); 784 delegate_->OnNativeWidgetPaint(canvas);
781 } 785 }
782 786
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 void NativeWidgetAura::OnGestureEvent(ui::GestureEvent* event) { 863 void NativeWidgetAura::OnGestureEvent(ui::GestureEvent* event) {
860 DCHECK(window_); 864 DCHECK(window_);
861 DCHECK(window_->IsVisible() || event->IsEndingEvent()); 865 DCHECK(window_->IsVisible() || event->IsEndingEvent());
862 delegate_->OnGestureEvent(event); 866 delegate_->OnGestureEvent(event);
863 } 867 }
864 868
865 //////////////////////////////////////////////////////////////////////////////// 869 ////////////////////////////////////////////////////////////////////////////////
866 // NativeWidgetAura, aura::client::ActivationDelegate implementation: 870 // NativeWidgetAura, aura::client::ActivationDelegate implementation:
867 871
868 bool NativeWidgetAura::ShouldActivate() const { 872 bool NativeWidgetAura::ShouldActivate() const {
869 return delegate_->CanActivate(); 873 return can_activate_ && delegate_->CanActivate();
870 } 874 }
871 875
872 //////////////////////////////////////////////////////////////////////////////// 876 ////////////////////////////////////////////////////////////////////////////////
873 // NativeWidgetAura, aura::client::ActivationChangeObserver implementation: 877 // NativeWidgetAura, aura::client::ActivationChangeObserver implementation:
874 878
875 void NativeWidgetAura::OnWindowActivated(aura::Window* gained_active, 879 void NativeWidgetAura::OnWindowActivated(aura::Window* gained_active,
876 aura::Window* lost_active) { 880 aura::Window* lost_active) {
877 DCHECK(window_ == gained_active || window_ == lost_active); 881 DCHECK(window_ == gained_active || window_ == lost_active);
878 if (GetWidget()->GetFocusManager()) { 882 if (GetWidget()->GetFocusManager()) {
879 if (window_ == gained_active) 883 if (window_ == gained_active)
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); 1157 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont));
1154 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); 1158 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont)));
1155 return gfx::FontList(gfx::Font(caption_font)); 1159 return gfx::FontList(gfx::Font(caption_font));
1156 #else 1160 #else
1157 return gfx::FontList(); 1161 return gfx::FontList();
1158 #endif 1162 #endif
1159 } 1163 }
1160 1164
1161 } // namespace internal 1165 } // namespace internal
1162 } // namespace views 1166 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/native_widget_aura.h ('k') | ui/views/widget/native_widget_aura_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698