diff --git a/ash/display/mouse_cursor_event_filter.cc b/ash/display/mouse_cursor_event_filter.cc index f5960d0ced01..29b417d0a823 100644 --- a/ash/display/mouse_cursor_event_filter.cc +++ b/ash/display/mouse_cursor_event_filter.cc @@ -210,13 +210,6 @@ void MouseCursorEventFilter::OnDisplayConfigurationChanged() { void MouseCursorEventFilter::OnMouseEvent(ui::MouseEvent* event) { aura::Window* target = static_cast(event->target()); - RootWindowController* rwc = GetRootWindowController(target->GetRootWindow()); - // The root window controller is removed during the shutting down - // RootWindow, so don't process events futher. - if (!rwc) { - event->StopPropagation(); - return; - } if (event->type() == ui::ET_MOUSE_PRESSED) { scale_when_drag_started_ = ui::GetDeviceScaleFactor(target->layer()); diff --git a/ash/display/screen_ash.cc b/ash/display/screen_ash.cc index 0348cbe26ace..607784dd8fc6 100644 --- a/ash/display/screen_ash.cc +++ b/ash/display/screen_ash.cc @@ -235,12 +235,11 @@ gfx::Display ScreenAsh::GetDisplayNearestWindow(gfx::NativeView window) const { if (!root_window) return GetPrimaryDisplay(); const RootWindowSettings* rws = GetRootWindowSettings(root_window); - if (rws->shutdown) - return GetPrimaryDisplay(); - int64 id = rws->display_id; // if id is |kInvaildDisplayID|, it's being deleted. DCHECK(id != gfx::Display::kInvalidDisplayID); + if (id == gfx::Display::kInvalidDisplayID) + return GetPrimaryDisplay(); DisplayManager* display_manager = GetDisplayManager(); // RootWindow needs Display to determine its device scale factor diff --git a/ash/host/ash_window_tree_host.h b/ash/host/ash_window_tree_host.h index 1d1513bffd57..b9c617fac976 100644 --- a/ash/host/ash_window_tree_host.h +++ b/ash/host/ash_window_tree_host.h @@ -53,7 +53,10 @@ class ASH_EXPORT AshWindowTreeHost { // mode dual monitors case). If the root window is only associated with one // display id, then the other id should be set to // gfx::Display::kInvalidDisplayID. - virtual void UpdateDisplayID(int64 id1, int64 id2) {}; + virtual void UpdateDisplayID(int64 id1, int64 id2) {} + + // Stop listening for events in preparation for shutdown. + virtual void PrepareForShutdown() {} }; } // namespace ash diff --git a/ash/host/ash_window_tree_host_x11.cc b/ash/host/ash_window_tree_host_x11.cc index eff9ba60f9e9..beb129ff97a7 100644 --- a/ash/host/ash_window_tree_host_x11.cc +++ b/ash/host/ash_window_tree_host_x11.cc @@ -19,9 +19,11 @@ #include "ui/aura/client/screen_position_client.h" #include "ui/aura/env.h" #include "ui/aura/window.h" +#include "ui/aura/window_event_dispatcher.h" #include "ui/base/x/x11_util.h" #include "ui/events/event.h" #include "ui/events/event_utils.h" +#include "ui/events/platform/platform_event_source.h" #include "ui/events/x/device_data_manager.h" #include "ui/events/x/device_list_cache_x.h" #include "ui/events/x/touch_factory_x11.h" @@ -129,6 +131,11 @@ void AshWindowTreeHostX11::UpdateDisplayID(int64 id1, int64 id2) { display_ids_.second = id2; } +void AshWindowTreeHostX11::PrepareForShutdown() { + if (ui::PlatformEventSource::GetInstance()) + ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); +} + void AshWindowTreeHostX11::SetBounds(const gfx::Rect& bounds) { WindowTreeHostX11::SetBounds(bounds); if (pointer_barriers_) { diff --git a/ash/host/ash_window_tree_host_x11.h b/ash/host/ash_window_tree_host_x11.h index 8b998beb9ff9..1a3335dd10ac 100644 --- a/ash/host/ash_window_tree_host_x11.h +++ b/ash/host/ash_window_tree_host_x11.h @@ -33,6 +33,7 @@ class ASH_EXPORT AshWindowTreeHostX11 : public AshWindowTreeHost, virtual gfx::Insets GetHostInsets() const OVERRIDE; virtual aura::WindowTreeHost* AsWindowTreeHost() OVERRIDE; virtual void UpdateDisplayID(int64 id1, int64 id2) OVERRIDE; + virtual void PrepareForShutdown() OVERRIDE; // aura::WindowTreehost: virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc index 2c0bb5f3d397..5a798d7d85c0 100644 --- a/ash/root_window_controller.cc +++ b/ash/root_window_controller.cc @@ -423,7 +423,7 @@ void RootWindowController::Shutdown() { // ends up with invalid display. GetRootWindowSettings(root_window)->display_id = gfx::Display::kInvalidDisplayID; - GetRootWindowSettings(root_window)->shutdown = true; + ash_host_->PrepareForShutdown(); system_background_.reset(); aura::client::SetScreenPositionClient(root_window, NULL); diff --git a/ash/root_window_settings.cc b/ash/root_window_settings.cc index 555c4c8baa8d..ed4931f88f1e 100644 --- a/ash/root_window_settings.cc +++ b/ash/root_window_settings.cc @@ -17,8 +17,7 @@ DEFINE_OWNED_WINDOW_PROPERTY_KEY(RootWindowSettings, RootWindowSettings::RootWindowSettings() : display_id(gfx::Display::kInvalidDisplayID), - controller(NULL), - shutdown(false) { + controller(NULL) { } RootWindowSettings* InitRootWindowSettings(aura::Window* root) { diff --git a/ash/root_window_settings.h b/ash/root_window_settings.h index 4982ac5da75e..dc6764738b72 100644 --- a/ash/root_window_settings.h +++ b/ash/root_window_settings.h @@ -28,9 +28,6 @@ struct RootWindowSettings { // RootWindowController for the root window. This may be NULL // for the root window used for mirroring. RootWindowController* controller; - - // True if the root window has already been shutdown. - bool shutdown; }; // Initializes and returns RootWindowSettings for |root|. diff --git a/ash/wm/coordinate_conversion.cc b/ash/wm/coordinate_conversion.cc index e32ddcdc1be5..991e7d4e1a0d 100644 --- a/ash/wm/coordinate_conversion.cc +++ b/ash/wm/coordinate_conversion.cc @@ -32,10 +32,7 @@ aura::Window* GetRootWindowMatching(const gfx::Rect& rect) { } void ConvertPointToScreen(const aura::Window* window, gfx::Point* point) { - // It is possible for the root window to not have a screen position client - // when switching multi-monitor mode from extended to mirror. - if (!aura::client::GetScreenPositionClient(window->GetRootWindow())) - return; + CHECK(aura::client::GetScreenPositionClient(window->GetRootWindow())); aura::client::GetScreenPositionClient(window->GetRootWindow())-> ConvertPointToScreen(window, point); } diff --git a/ash/wm/root_window_layout_manager.cc b/ash/wm/root_window_layout_manager.cc index 282dbed08dd7..65b71f44b9bd 100644 --- a/ash/wm/root_window_layout_manager.cc +++ b/ash/wm/root_window_layout_manager.cc @@ -6,7 +6,6 @@ #include "ash/desktop_background/desktop_background_widget_controller.h" #include "ash/root_window_controller.h" -#include "ash/root_window_settings.h" #include "ui/aura/window_event_dispatcher.h" #include "ui/compositor/layer.h" #include "ui/views/widget/widget.h" @@ -28,10 +27,6 @@ RootWindowLayoutManager::~RootWindowLayoutManager() { // RootWindowLayoutManager, aura::LayoutManager implementation: void RootWindowLayoutManager::OnWindowResized() { - // X event may arrive during shutdown. - if (GetRootWindowSettings(owner_->GetRootWindow())->shutdown) - return; - gfx::Rect fullscreen_bounds = gfx::Rect(owner_->bounds().width(), owner_->bounds().height());