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

Unified Diff: ui/views/widget/widget.cc

Issue 2650833002: Set focusibility correctly when initializing a window in mus+ash. (Closed)
Patch Set: addressed feedback. Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/widget/widget.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/widget.cc
diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc
index 0008141679a270ad77cb56908a7cc1ee321ebc72..4d0e7cf91664663f360b9210848b4674417faff4 100644
--- a/ui/views/widget/widget.cc
+++ b/ui/views/widget/widget.cc
@@ -142,6 +142,14 @@ Widget::InitParams::InitParams(const InitParams& other) = default;
Widget::InitParams::~InitParams() {
}
+bool Widget::InitParams::CanActivate() const {
+ if (activatable != InitParams::ACTIVATABLE_DEFAULT)
+ return activatable == InitParams::ACTIVATABLE_YES;
+ return type != InitParams::TYPE_CONTROL && type != InitParams::TYPE_POPUP &&
+ type != InitParams::TYPE_MENU && type != InitParams::TYPE_TOOLTIP &&
+ type != InitParams::TYPE_DRAG;
+}
+
////////////////////////////////////////////////////////////////////////////////
// Widget, public:
@@ -309,20 +317,9 @@ void Widget::Init(const InitParams& in_params) {
if (params.opacity == views::Widget::InitParams::INFER_OPACITY)
params.opacity = views::Widget::InitParams::OPAQUE_WINDOW;
- bool can_activate = false;
- if (params.activatable != InitParams::ACTIVATABLE_DEFAULT) {
- can_activate = (params.activatable == InitParams::ACTIVATABLE_YES);
- } else if (params.type != InitParams::TYPE_CONTROL &&
- params.type != InitParams::TYPE_POPUP &&
- params.type != InitParams::TYPE_MENU &&
- params.type != InitParams::TYPE_TOOLTIP &&
- params.type != InitParams::TYPE_DRAG) {
- can_activate = true;
- params.activatable = InitParams::ACTIVATABLE_YES;
- } else {
- can_activate = false;
- params.activatable = InitParams::ACTIVATABLE_NO;
- }
+ bool can_activate = params.CanActivate();
+ params.activatable =
+ can_activate ? InitParams::ACTIVATABLE_YES : InitParams::ACTIVATABLE_NO;
widget_delegate_ = params.delegate ?
params.delegate : new DefaultWidgetDelegate(this);
« no previous file with comments | « ui/views/widget/widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698