Skip to content

Commit

Permalink
Revert 128503 - Remove stops_event_propagation from Window, since it'…
Browse files Browse the repository at this point in the history
…s broken.

Changes it to be implemented by the Aura client, via a new interface EventClient.
The client can determine whether or not a given window and its subtree can receive events.
I also cleaned up the way screen locking is entered/exited via the delegate, and some stuff in ash/shell.

http://crbug.com/119347
TEST=none
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=128328
Review URL: https://chromiumcodereview.appspot.com/9788001

TBR=ben@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9808068

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128508 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
jam@chromium.org committed Mar 23, 2012
1 parent 7d733b4 commit b227ed7
Show file tree
Hide file tree
Showing 36 changed files with 390 additions and 892 deletions.
13 changes: 8 additions & 5 deletions ash/accelerators/nested_dispatcher_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "ash/accelerators/accelerator_controller.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h"
#include "ash/test/ash_test_base.h"
#include "base/bind.h"
Expand Down Expand Up @@ -115,18 +114,21 @@ TEST_F(NestedDispatcherTest, AssociatedWindowBelowLockScreen) {
MockDispatcher inner_dispatcher;
aura::Window* default_container = Shell::GetInstance()->GetContainer(
internal::kShellWindowId_DefaultContainer);
scoped_ptr<aura::Window> associated_window(aura::test::CreateTestWindowWithId(
scoped_ptr<aura::Window>associated_window(aura::test::CreateTestWindowWithId(
0, default_container));

Shell::GetInstance()->delegate()->LockScreen();
scoped_ptr<aura::Window>mock_lock_container(
aura::test::CreateTestWindowWithId(0, default_container));
mock_lock_container->set_stops_event_propagation(true);
aura::test::CreateTestWindowWithId(0, mock_lock_container.get());
EXPECT_TRUE(aura::test::WindowIsAbove(mock_lock_container.get(),
associated_window.get()));
DispatchKeyReleaseA();
aura::RootWindow* root_window = ash::Shell::GetInstance()->GetRootWindow();
aura::client::GetDispatcherClient(root_window)->RunWithDispatcher(
&inner_dispatcher,
associated_window.get(),
true /* nestable_tasks_allowed */);
EXPECT_EQ(0, inner_dispatcher.num_key_events_dispatched());
Shell::GetInstance()->delegate()->UnlockScreen();
}

// Aura window above lock screen in z order.
Expand All @@ -137,6 +139,7 @@ TEST_F(NestedDispatcherTest, AssociatedWindowAboveLockScreen) {
internal::kShellWindowId_DefaultContainer);
scoped_ptr<aura::Window>mock_lock_container(
aura::test::CreateTestWindowWithId(0, default_container));
mock_lock_container->set_stops_event_propagation(true);
aura::test::CreateTestWindowWithId(0, mock_lock_container.get());
scoped_ptr<aura::Window>associated_window(aura::test::CreateTestWindowWithId(
0, default_container));
Expand Down
8 changes: 0 additions & 8 deletions ash/ash.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@
'wm/default_window_resizer.h',
'wm/dialog_frame_view.cc',
'wm/dialog_frame_view.h',
'wm/event_client_impl.cc',
'wm/event_client_impl.h',
'wm/frame_painter.cc',
'wm/frame_painter.h',
'wm/image_grid.cc',
Expand Down Expand Up @@ -427,13 +425,9 @@
'shell/app_list.cc',
'shell/bubble.cc',
'shell/example_factory.h',
'shell/launcher_delegate_impl.cc',
'shell/launcher_delegate_impl.h',
'shell/lock_view.cc',
'shell/panel_window.cc',
'shell/panel_window.h',
'shell/shell_delegate_impl.cc',
'shell/shell_delegate_impl.h',
'shell/shell_main.cc',
'shell/shell_main_parts.cc',
'shell/shell_main_parts.h',
Expand All @@ -443,8 +437,6 @@
'shell/widgets.cc',
'shell/window_type_launcher.cc',
'shell/window_type_launcher.h',
'shell/window_watcher.cc',
'shell/window_watcher.h',
'<(SHARED_INTERMEDIATE_DIR)/ui/gfx/gfx_resources.rc',
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources_standard/ui_resources_standard.rc',
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/ui_resources.rc',
Expand Down
11 changes: 4 additions & 7 deletions ash/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#include "ash/wm/base_layout_manager.h"
#include "ash/wm/custom_frame_view_ash.h"
#include "ash/wm/dialog_frame_view.h"
#include "ash/wm/event_client_impl.h"
#include "ash/wm/panel_window_event_filter.h"
#include "ash/wm/panel_layout_manager.h"
#include "ash/wm/partial_screenshot_event_filter.h"
Expand Down Expand Up @@ -191,7 +190,7 @@ void CreateSpecialContainers(aura::RootWindow* root_window) {
lock_screen_containers);
lock_container->SetLayoutManager(
new internal::BaseLayoutManager(root_window));
// TODO(beng): stopsevents
lock_container->set_stops_event_propagation(true);

aura::Window* lock_modal_container = CreateContainer(
internal::kShellWindowId_LockSystemModalContainer,
Expand Down Expand Up @@ -545,8 +544,6 @@ Shell::~Shell() {
resize_shadow_controller_.reset();
shadow_controller_.reset();
window_cycle_controller_.reset();
event_client_.reset();
monitor_controller_.reset();

// Launcher widget has a InputMethodBridge that references to
// input_method_filter_'s input_method_. So explicitly release launcher_
Expand Down Expand Up @@ -632,8 +629,6 @@ void Shell::Init() {
root_window_layout_ = new internal::RootWindowLayoutManager(root_window);
root_window->SetLayoutManager(root_window_layout_);

event_client_.reset(new internal::EventClientImpl(root_window));

if (delegate_.get())
status_widget_ = delegate_->CreateStatusArea();

Expand Down Expand Up @@ -771,7 +766,9 @@ void Shell::ToggleAppList() {
}

bool Shell::IsScreenLocked() const {
return !delegate_.get() || delegate_->IsScreenLocked();
const aura::Window* lock_screen_container = GetContainer(
internal::kShellWindowId_LockScreenContainer);
return lock_screen_container->StopsEventPropagation();
}

bool Shell::IsModalWindowOpen() const {
Expand Down
2 changes: 0 additions & 2 deletions ash/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class ActivationController;
class AcceleratorFilter;
class AppList;
class DragDropController;
class EventClientImpl;
class FocusCycler;
class InputMethodEventFilter;
class MonitorController;
Expand Down Expand Up @@ -284,7 +283,6 @@ class ASH_EXPORT Shell {
scoped_ptr<VideoDetector> video_detector_;
scoped_ptr<WindowCycleController> window_cycle_controller_;
scoped_ptr<internal::FocusCycler> focus_cycler_;
scoped_ptr<internal::EventClientImpl> event_client_;
scoped_ptr<internal::MonitorController> monitor_controller_;

// An event filter that pre-handles all key events to send them to an IME.
Expand Down
4 changes: 1 addition & 3 deletions ash/shell/app_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#include "ash/app_list/app_list_model.h"
#include "ash/app_list/app_list_view_delegate.h"
#include "ash/app_list/app_list_view.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell/example_factory.h"
#include "ash/shell/toplevel_window.h"
#include "base/basictypes.h"
Expand Down Expand Up @@ -82,7 +80,7 @@ class WindowTypeLauncherItem : public ash::AppListItemModel {
break;
}
case LOCK_SCREEN: {
Shell::GetInstance()->delegate()->LockScreen();
CreateLockScreen();
break;
}
case WIDGETS_WINDOW: {
Expand Down
54 changes: 0 additions & 54 deletions ash/shell/launcher_delegate_impl.cc

This file was deleted.

47 changes: 0 additions & 47 deletions ash/shell/launcher_delegate_impl.h

This file was deleted.

46 changes: 8 additions & 38 deletions ash/shell/lock_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// found in the LICENSE file.

#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h"
#include "ash/shell/example_factory.h"
#include "ash/tooltips/tooltip_controller.h"
Expand All @@ -12,7 +11,6 @@
#include "ui/aura/window.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/font.h"
#include "ui/views/controls/button/text_button.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"

Expand All @@ -21,23 +19,18 @@ using ash::Shell;
namespace ash {
namespace shell {

class LockView : public views::WidgetDelegateView,
public views::ButtonListener {
class LockView : public views::WidgetDelegateView {
public:
LockView() : unlock_button_(ALLOW_THIS_IN_INITIALIZER_LIST(
new views::NativeTextButton(this, ASCIIToUTF16("Unlock")))) {
AddChildView(unlock_button_);
unlock_button_->set_focusable(true);
}
LockView() {}
virtual ~LockView() {}

// Overridden from views::View:
// Overridden from View:
virtual gfx::Size GetPreferredSize() OVERRIDE {
return gfx::Size(500, 400);
}

private:
// Overridden from views::View:
// Overridden from View:
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
canvas->FillRect(GetLocalBounds(), SK_ColorYELLOW);
string16 text = ASCIIToUTF16("LOCKED!");
Expand All @@ -46,44 +39,22 @@ class LockView : public views::WidgetDelegateView,
(height() - font_.GetHeight()) / 2,
string_width, font_.GetHeight());
}
virtual void Layout() OVERRIDE {
gfx::Rect bounds = GetLocalBounds();
gfx::Size ps = unlock_button_->GetPreferredSize();
bounds.set_y(bounds.bottom() - ps.height() - 5);
bounds.set_x((bounds.width() - ps.width()) / 2);
bounds.set_size(ps);
unlock_button_->SetBoundsRect(bounds);
}
virtual void ViewHierarchyChanged(bool is_add,
views::View* parent,
views::View* child) OVERRIDE {
if (is_add && child == this)
unlock_button_->RequestFocus();
virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE {
return true;
}

// Overridden from views::WidgetDelegateView:
virtual void WindowClosing() OVERRIDE {
Shell::GetInstance()->delegate()->UnlockScreen();
}

// Overridden from views::ButtonListener:
virtual void ButtonPressed(views::Button* sender,
const views::Event& event) OVERRIDE {
DCHECK(sender == unlock_button_);
virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE {
GetWidget()->Close();
}

gfx::Font font_;
views::NativeTextButton* unlock_button_;

DISALLOW_COPY_AND_ASSIGN(LockView);
};

void CreateLockScreen() {
LockView* lock_view = new LockView;
views::Widget* widget = new views::Widget;
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL);
gfx::Size ps = lock_view->GetPreferredSize();

gfx::Size root_window_size = Shell::GetRootWindow()->bounds().size();
Expand All @@ -98,7 +69,6 @@ void CreateLockScreen() {
widget->SetContentsView(lock_view);
widget->Show();
widget->GetNativeView()->SetName("LockView");
widget->GetNativeView()->Focus();

Shell::GetInstance()->tooltip_controller()->UpdateTooltip(
widget->GetNativeView());
Expand Down
Loading

0 comments on commit b227ed7

Please sign in to comment.