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

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

Issue 286733002: [Refactor] Consolidate the logic for whether a widget can be activated. (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 side-by-side diff with in-line comments
Download patch
Index: ui/views/widget/widget.cc
diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc
index d773f1fef801553c975d07fc9586e520a4b93a5e..dd7dd83fd4cce9d44acd8c72e74a3f2352c1d930 100644
--- a/ui/views/widget/widget.cc
+++ b/ui/views/widget/widget.cc
@@ -69,11 +69,9 @@ NativeWidget* CreateNativeWidget(NativeWidget* native_widget,
// WidgetDelegate is supplied.
class DefaultWidgetDelegate : public WidgetDelegate {
public:
- DefaultWidgetDelegate(Widget* widget, const Widget::InitParams& params)
+ DefaultWidgetDelegate(Widget* widget, bool can_activate)
: widget_(widget),
- can_activate_(!params.child &&
- params.type != Widget::InitParams::TYPE_POPUP &&
- params.type != Widget::InitParams::TYPE_DRAG) {
+ can_activate_(can_activate) {
}
virtual ~DefaultWidgetDelegate() {}
@@ -113,7 +111,7 @@ Widget::InitParams::InitParams()
child(false),
opacity(INFER_OPACITY),
accept_events(true),
- can_activate(true),
+ activatable(ACTIVATABLE_DEFAULT),
keep_on_top(false),
visible_on_all_workspaces(false),
ownership(NATIVE_WIDGET_OWNS_WIDGET),
@@ -138,8 +136,7 @@ Widget::InitParams::InitParams(Type type)
child(type == TYPE_CONTROL),
opacity(INFER_OPACITY),
accept_events(true),
- can_activate(type != TYPE_POPUP && type != TYPE_MENU &&
- type != TYPE_DRAG),
+ activatable(ACTIVATABLE_DEFAULT),
keep_on_top(type == TYPE_MENU || type == TYPE_DRAG),
pkotwicz 2014/05/14 00:44:06 In a separate CL, I can move the computation of |k
visible_on_all_workspaces(false),
ownership(NATIVE_WIDGET_OWNS_WIDGET),
@@ -347,6 +344,20 @@ void Widget::Init(const InitParams& in_params) {
params.type != InitParams::TYPE_TOOLTIP);
params.top_level = is_top_level_;
+ 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;
+ }
+
if (params.opacity == views::Widget::InitParams::INFER_OPACITY &&
params.type != views::Widget::InitParams::TYPE_WINDOW &&
params.type != views::Widget::InitParams::TYPE_PANEL)
@@ -359,7 +370,7 @@ void Widget::Init(const InitParams& in_params) {
params.opacity = views::Widget::InitParams::OPAQUE_WINDOW;
widget_delegate_ = params.delegate ?
- params.delegate : new DefaultWidgetDelegate(this, params);
+ params.delegate : new DefaultWidgetDelegate(this, can_activate_);
ownership_ = params.ownership;
native_widget_ = CreateNativeWidget(params.native_widget, this)->
AsNativeWidgetPrivate();
@@ -1008,7 +1019,7 @@ bool Widget::IsDialogBox() const {
}
bool Widget::CanActivate() const {
- return widget_delegate_->CanActivate();
+ return can_activate_ && widget_delegate_->CanActivate();
}
bool Widget::IsInactiveRenderingDisabled() const {

Powered by Google App Engine
This is Rietveld 408576698