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

Side by Side Diff: ui/views/mus/native_widget_mus.cc

Issue 2371113003: Do not give instant focus if a view's toplevelwidget is not active (Closed)
Patch Set: fix test failures Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 // This has to be before any other includes, else default is picked up. 5 // This has to be before any other includes, else default is picked up.
6 // See base/logging for details on this. 6 // See base/logging for details on this.
7 #define NOTIMPLEMENTED_POLICY 5 7 #define NOTIMPLEMENTED_POLICY 5
8 8
9 #include "ui/views/mus/native_widget_mus.h" 9 #include "ui/views/mus/native_widget_mus.h"
10 10
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 if (state == ui::SHOW_STATE_MINIMIZED) 1088 if (state == ui::SHOW_STATE_MINIMIZED)
1089 Minimize(); 1089 Minimize();
1090 } 1090 }
1091 1091
1092 bool NativeWidgetMus::IsVisible() const { 1092 bool NativeWidgetMus::IsVisible() const {
1093 // TODO(beng): this should probably be wired thru PlatformWindow. 1093 // TODO(beng): this should probably be wired thru PlatformWindow.
1094 return window_ && window_->visible(); 1094 return window_ && window_->visible();
1095 } 1095 }
1096 1096
1097 void NativeWidgetMus::Activate() { 1097 void NativeWidgetMus::Activate() {
1098 if (!window_)
1099 return;
1100
1098 static_cast<aura::client::ActivationClient*>(focus_client_.get()) 1101 static_cast<aura::client::ActivationClient*>(focus_client_.get())
1099 ->ActivateWindow(content_); 1102 ->ActivateWindow(content_);
1100 // FocusControllerMus should have focused |window_| when |content_| is
1101 // activated.
1102 DCHECK(!window_ || window_->HasFocus());
1103 } 1103 }
1104 1104
1105 void NativeWidgetMus::Deactivate() { 1105 void NativeWidgetMus::Deactivate() {
1106 if (IsActive()) 1106 if (IsActive())
1107 window_->window_tree()->ClearFocus(); 1107 window_->window_tree()->ClearFocus();
1108 } 1108 }
1109 1109
1110 bool NativeWidgetMus::IsActive() const { 1110 bool NativeWidgetMus::IsActive() const {
1111 ui::Window* focused = 1111 ui::Window* focused =
1112 window_ ? window_->window_tree()->GetFocusedWindow() : nullptr; 1112 window_ ? window_->window_tree()->GetFocusedWindow() : nullptr;
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1536 1536
1537 gfx::Path mask_path; 1537 gfx::Path mask_path;
1538 native_widget_delegate_->GetHitTestMask(&mask_path); 1538 native_widget_delegate_->GetHitTestMask(&mask_path);
1539 // TODO(jamescook): Use the full path for the mask. 1539 // TODO(jamescook): Use the full path for the mask.
1540 gfx::Rect mask_rect = 1540 gfx::Rect mask_rect =
1541 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); 1541 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds()));
1542 window_->SetHitTestMask(mask_rect); 1542 window_->SetHitTestMask(mask_rect);
1543 } 1543 }
1544 1544
1545 } // namespace views 1545 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698