Skip to content

Commit

Permalink
Remove dispatcher when shutting down RootWindowController
Browse files Browse the repository at this point in the history
Resurrecting PrepareForShutdown as it can be implemented onl in ash.

BUG=None

Review URL: https://codereview.chromium.org/294073006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272308 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
oshima@chromium.org committed May 22, 2014
1 parent 78cd68e commit 8f5209c
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 26 deletions.
7 changes: 0 additions & 7 deletions ash/display/mouse_cursor_event_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,6 @@ void MouseCursorEventFilter::OnDisplayConfigurationChanged() {

void MouseCursorEventFilter::OnMouseEvent(ui::MouseEvent* event) {
aura::Window* target = static_cast<aura::Window*>(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());
Expand Down
5 changes: 2 additions & 3 deletions ash/display/screen_ash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion ash/host/ash_window_tree_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions ash/host/ash_window_tree_host_x11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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_) {
Expand Down
1 change: 1 addition & 0 deletions ash/host/ash_window_tree_host_x11.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ash/root_window_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions ash/root_window_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 0 additions & 3 deletions ash/root_window_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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|.
Expand Down
5 changes: 1 addition & 4 deletions ash/wm/coordinate_conversion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
5 changes: 0 additions & 5 deletions ash/wm/root_window_layout_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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());

Expand Down

0 comments on commit 8f5209c

Please sign in to comment.