diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-06 03:52:12 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-06 03:52:12 +0000 |
commit | 2a906c0076ac3f7efd17450f12869c7c3429f983 (patch) | |
tree | 82b9d94ea5c21f609aed47432208dd4212fc6290 /ui/views | |
parent | 42c86025c01c567bbfaeceeb21a900baa21ed14e (diff) | |
download | chromium_src-2a906c0076ac3f7efd17450f12869c7c3429f983.zip chromium_src-2a906c0076ac3f7efd17450f12869c7c3429f983.tar.gz chromium_src-2a906c0076ac3f7efd17450f12869c7c3429f983.tar.bz2 |
Makes Widget modality a 3-state type rather than a boolean.
There are actually two types of modality that the WM might care about - window modality and system modality. See the definitions of these in ui/base/ui_base_types.h.
This is a precursor to adding support for window modality to Ash. Right now we only do system modality which is undesirable for almost all cases of window modality.
http://crbug.com/109290
TEST=none
Review URL: http://codereview.chromium.org/9109035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116644 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views')
-rw-r--r-- | ui/views/widget/native_widget_aura.cc | 5 | ||||
-rw-r--r-- | ui/views/widget/native_widget_aura.h | 2 | ||||
-rw-r--r-- | ui/views/widget/native_widget_gtk.cc | 4 | ||||
-rw-r--r-- | ui/views/widget/native_widget_gtk.h | 2 | ||||
-rw-r--r-- | ui/views/widget/native_widget_private.h | 7 | ||||
-rw-r--r-- | ui/views/widget/native_widget_win.cc | 4 | ||||
-rw-r--r-- | ui/views/widget/native_widget_win.h | 2 | ||||
-rw-r--r-- | ui/views/widget/widget.cc | 5 | ||||
-rw-r--r-- | ui/views/widget/widget_delegate.cc | 6 | ||||
-rw-r--r-- | ui/views/widget/widget_delegate.h | 8 |
10 files changed, 26 insertions, 19 deletions
diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc index 2c5c2c1..b99aa40 100644 --- a/ui/views/widget/native_widget_aura.cc +++ b/ui/views/widget/native_widget_aura.cc @@ -356,8 +356,9 @@ void NativeWidgetAura::SetAccessibleState(ui::AccessibilityTypes::State state) { //NOTIMPLEMENTED(); } -void NativeWidgetAura::BecomeModal() { - window_->SetIntProperty(aura::client::kModalKey, 1); +void NativeWidgetAura::InitModalType(ui::ModalType modal_type) { + if (modal_type != ui::MODAL_TYPE_NONE) + window_->SetIntProperty(aura::client::kModalKey, modal_type); } gfx::Rect NativeWidgetAura::GetWindowScreenBounds() const { diff --git a/ui/views/widget/native_widget_aura.h b/ui/views/widget/native_widget_aura.h index a4eb003..af84d53 100644 --- a/ui/views/widget/native_widget_aura.h +++ b/ui/views/widget/native_widget_aura.h @@ -78,7 +78,7 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate, virtual void SetAccessibleName(const string16& name) OVERRIDE; virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) OVERRIDE; virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE; - virtual void BecomeModal() OVERRIDE; + virtual void InitModalType(ui::ModalType modal_type) OVERRIDE; virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE; virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE; virtual gfx::Rect GetRestoredBounds() const OVERRIDE; diff --git a/ui/views/widget/native_widget_gtk.cc b/ui/views/widget/native_widget_gtk.cc index ba17eec..8e62bff 100644 --- a/ui/views/widget/native_widget_gtk.cc +++ b/ui/views/widget/native_widget_gtk.cc @@ -981,7 +981,9 @@ void NativeWidgetGtk::SetAccessibleRole(ui::AccessibilityTypes::Role role) { void NativeWidgetGtk::SetAccessibleState(ui::AccessibilityTypes::State state) { } -void NativeWidgetGtk::BecomeModal() { +void NativeWidgetGtk::InitModalType(ui::ModalType modal_type) { + if (modal_type == ui::MODAL_TYPE_NONE) + return; gtk_window_set_modal(GetNativeWindow(), true); } diff --git a/ui/views/widget/native_widget_gtk.h b/ui/views/widget/native_widget_gtk.h index dd0f8d7..dc9973f 100644 --- a/ui/views/widget/native_widget_gtk.h +++ b/ui/views/widget/native_widget_gtk.h @@ -182,7 +182,7 @@ class VIEWS_EXPORT NativeWidgetGtk : public internal::NativeWidgetPrivate, virtual void SetAccessibleName(const string16& name) OVERRIDE; virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) OVERRIDE; virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE; - virtual void BecomeModal() OVERRIDE; + virtual void InitModalType(ui::ModalType modal_type) OVERRIDE; virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE; virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE; virtual gfx::Rect GetRestoredBounds() const OVERRIDE; diff --git a/ui/views/widget/native_widget_private.h b/ui/views/widget/native_widget_private.h index 46441fd..ee94178 100644 --- a/ui/views/widget/native_widget_private.h +++ b/ui/views/widget/native_widget_private.h @@ -7,6 +7,7 @@ #pragma once #include "base/string16.h" +#include "ui/base/ui_base_types.h" #include "ui/gfx/native_widget_types.h" #include "ui/views/ime/input_method_delegate.h" #include "ui/views/widget/native_widget.h" @@ -158,8 +159,10 @@ class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget, virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) = 0; virtual void SetAccessibleState(ui::AccessibilityTypes::State state) = 0; - // Makes the NativeWindow modal. - virtual void BecomeModal() = 0; + // Initializes the modal type of the window to |modal_type|. Called from + // NativeWidgetDelegate::OnNativeWidgetCreated() before the widget is + // initially parented. + virtual void InitModalType(ui::ModalType modal_type) = 0; // See method documentation in Widget. virtual gfx::Rect GetWindowScreenBounds() const = 0; diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc index d0e57c7..fbf3834 100644 --- a/ui/views/widget/native_widget_win.cc +++ b/ui/views/widget/native_widget_win.cc @@ -772,7 +772,9 @@ void NativeWidgetWin::SetAccessibleState(ui::AccessibilityTypes::State state) { } } -void NativeWidgetWin::BecomeModal() { +void NativeWidgetWin::InitModalType(ui::ModalType modal_type) { + if (modal_type == ui::MODAL_TYPE_NONE) + return; // We implement modality by crawling up the hierarchy of windows starting // at the owner, disabling all of them so that they don't receive input // messages. diff --git a/ui/views/widget/native_widget_win.h b/ui/views/widget/native_widget_win.h index c6cd9c8..ab40897 100644 --- a/ui/views/widget/native_widget_win.h +++ b/ui/views/widget/native_widget_win.h @@ -214,7 +214,7 @@ class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl, virtual void SetAccessibleName(const string16& name) OVERRIDE; virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) OVERRIDE; virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE; - virtual void BecomeModal() OVERRIDE; + virtual void InitModalType(ui::ModalType modal_type) OVERRIDE; virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE; virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE; virtual gfx::Rect GetRestoredBounds() const OVERRIDE; diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc index 51fed47..d00eedd 100644 --- a/ui/views/widget/widget.cc +++ b/ui/views/widget/widget.cc @@ -854,7 +854,7 @@ gfx::Rect Widget::GetWorkAreaBoundsInScreen() const { // Widget, NativeWidgetDelegate implementation: bool Widget::IsModal() const { - return widget_delegate_->IsModal(); + return widget_delegate_->GetModalType() != ui::MODAL_TYPE_NONE; } bool Widget::IsDialogBox() const { @@ -915,8 +915,7 @@ void Widget::OnNativeWidgetCreated() { native_widget_->SetAccessibleState( widget_delegate_->GetAccessibleWindowState()); - if (widget_delegate_->IsModal()) - native_widget_->BecomeModal(); + native_widget_->InitModalType(widget_delegate_->GetModalType()); } void Widget::OnNativeWidgetDestroying() { diff --git a/ui/views/widget/widget_delegate.cc b/ui/views/widget/widget_delegate.cc index 6456c61..a492ebd 100644 --- a/ui/views/widget/widget_delegate.cc +++ b/ui/views/widget/widget_delegate.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -53,8 +53,8 @@ bool WidgetDelegate::CanActivate() const { return true; } -bool WidgetDelegate::IsModal() const { - return false; +ui::ModalType WidgetDelegate::GetModalType() const { + return ui::MODAL_TYPE_NONE; } ui::AccessibilityTypes::Role WidgetDelegate::GetAccessibleWindowRole() const { diff --git a/ui/views/widget/widget_delegate.h b/ui/views/widget/widget_delegate.h index 58a2c72..0acc28ad 100644 --- a/ui/views/widget/widget_delegate.h +++ b/ui/views/widget/widget_delegate.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -62,9 +62,9 @@ class VIEWS_EXPORT WidgetDelegate { // Returns true if the window can be activated. virtual bool CanActivate() const; - // Returns true if the dialog should be displayed modally to the window that - // opened it. Only windows with WindowType == DIALOG can be modal. - virtual bool IsModal() const; + // Returns the modal type that applies to the widget. Default is + // ui::MODAL_TYPE_NONE (not modal). + virtual ui::ModalType GetModalType() const; virtual ui::AccessibilityTypes::Role GetAccessibleWindowRole() const; |