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

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

Issue 2650833002: Set focusibility correctly when initializing a window in mus+ash. (Closed)
Patch Set: 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 unified diff | Download patch
« ui/views/mus/mus_client.cc ('K') | « ui/views/widget/widget.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) 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/widget.h" 5 #include "ui/views/widget/widget.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 layer_type(ui::LAYER_TEXTURED), 134 layer_type(ui::LAYER_TEXTURED),
135 context(nullptr), 135 context(nullptr),
136 force_show_in_taskbar(false), 136 force_show_in_taskbar(false),
137 force_software_compositing(false) {} 137 force_software_compositing(false) {}
138 138
139 Widget::InitParams::InitParams(const InitParams& other) = default; 139 Widget::InitParams::InitParams(const InitParams& other) = default;
140 140
141 Widget::InitParams::~InitParams() { 141 Widget::InitParams::~InitParams() {
142 } 142 }
143 143
144 bool Widget::InitParams::CanActivate() const {
sky 2017/01/23 21:28:29 Are you sure you need to create a function for thi
Hadi 2017/01/24 18:42:33 I logged activatable at MusClient::ConfigureProper
145 if (activatable != InitParams::ACTIVATABLE_DEFAULT) {
146 return activatable == InitParams::ACTIVATABLE_YES;
147 } else {
sky 2017/01/23 21:28:29 no else after a return (see style guide).
Hadi 2017/01/24 18:42:33 Done.
148 return type != InitParams::TYPE_CONTROL && type != InitParams::TYPE_POPUP &&
149 type != InitParams::TYPE_MENU && type != InitParams::TYPE_TOOLTIP &&
150 type != InitParams::TYPE_DRAG;
151 }
152 }
153
144 //////////////////////////////////////////////////////////////////////////////// 154 ////////////////////////////////////////////////////////////////////////////////
145 // Widget, public: 155 // Widget, public:
146 156
147 Widget::Widget() 157 Widget::Widget()
148 : native_widget_(nullptr), 158 : native_widget_(nullptr),
149 widget_delegate_(nullptr), 159 widget_delegate_(nullptr),
150 non_client_view_(nullptr), 160 non_client_view_(nullptr),
151 dragged_view_(nullptr), 161 dragged_view_(nullptr),
152 ownership_(InitParams::NATIVE_WIDGET_OWNS_WIDGET), 162 ownership_(InitParams::NATIVE_WIDGET_OWNS_WIDGET),
153 is_secondary_widget_(true), 163 is_secondary_widget_(true),
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 params.type != views::Widget::InitParams::TYPE_WINDOW && 312 params.type != views::Widget::InitParams::TYPE_WINDOW &&
303 params.type != views::Widget::InitParams::TYPE_PANEL) 313 params.type != views::Widget::InitParams::TYPE_PANEL)
304 params.opacity = views::Widget::InitParams::OPAQUE_WINDOW; 314 params.opacity = views::Widget::InitParams::OPAQUE_WINDOW;
305 315
306 if (ViewsDelegate::GetInstance()) 316 if (ViewsDelegate::GetInstance())
307 ViewsDelegate::GetInstance()->OnBeforeWidgetInit(&params, this); 317 ViewsDelegate::GetInstance()->OnBeforeWidgetInit(&params, this);
308 318
309 if (params.opacity == views::Widget::InitParams::INFER_OPACITY) 319 if (params.opacity == views::Widget::InitParams::INFER_OPACITY)
310 params.opacity = views::Widget::InitParams::OPAQUE_WINDOW; 320 params.opacity = views::Widget::InitParams::OPAQUE_WINDOW;
311 321
312 bool can_activate = false; 322 bool can_activate = params.CanActivate();
313 if (params.activatable != InitParams::ACTIVATABLE_DEFAULT) { 323 params.activatable =
314 can_activate = (params.activatable == InitParams::ACTIVATABLE_YES); 324 can_activate ? InitParams::ACTIVATABLE_YES : InitParams::ACTIVATABLE_NO;
315 } else if (params.type != InitParams::TYPE_CONTROL &&
316 params.type != InitParams::TYPE_POPUP &&
317 params.type != InitParams::TYPE_MENU &&
318 params.type != InitParams::TYPE_TOOLTIP &&
319 params.type != InitParams::TYPE_DRAG) {
320 can_activate = true;
321 params.activatable = InitParams::ACTIVATABLE_YES;
322 } else {
323 can_activate = false;
324 params.activatable = InitParams::ACTIVATABLE_NO;
325 }
326 325
327 widget_delegate_ = params.delegate ? 326 widget_delegate_ = params.delegate ?
328 params.delegate : new DefaultWidgetDelegate(this); 327 params.delegate : new DefaultWidgetDelegate(this);
329 widget_delegate_->set_can_activate(can_activate); 328 widget_delegate_->set_can_activate(can_activate);
330 329
331 ownership_ = params.ownership; 330 ownership_ = params.ownership;
332 native_widget_ = CreateNativeWidget(params, this)->AsNativeWidgetPrivate(); 331 native_widget_ = CreateNativeWidget(params, this)->AsNativeWidgetPrivate();
333 root_view_.reset(CreateRootView()); 332 root_view_.reset(CreateRootView());
334 default_theme_provider_.reset(new ui::DefaultThemeProvider); 333 default_theme_provider_.reset(new ui::DefaultThemeProvider);
335 if (params.type == InitParams::TYPE_MENU) { 334 if (params.type == InitParams::TYPE_MENU) {
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1496 1495
1497 //////////////////////////////////////////////////////////////////////////////// 1496 ////////////////////////////////////////////////////////////////////////////////
1498 // internal::NativeWidgetPrivate, NativeWidget implementation: 1497 // internal::NativeWidgetPrivate, NativeWidget implementation:
1499 1498
1500 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { 1499 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() {
1501 return this; 1500 return this;
1502 } 1501 }
1503 1502
1504 } // namespace internal 1503 } // namespace internal
1505 } // namespace views 1504 } // namespace views
OLDNEW
« ui/views/mus/mus_client.cc ('K') | « ui/views/widget/widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698