diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-29 20:55:29 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-29 20:55:29 +0000 |
commit | 0d44a3023daa43452075d4a712422fad8fa78195 (patch) | |
tree | 48fc4df2c8dbb31a6a925a57f917f3d2f2893de0 /ui | |
parent | 9d161d2d6f5976f1e6f8df8e23054c25572ee1a9 (diff) | |
download | chromium_src-0d44a3023daa43452075d4a712422fad8fa78195.zip chromium_src-0d44a3023daa43452075d4a712422fad8fa78195.tar.gz chromium_src-0d44a3023daa43452075d4a712422fad8fa78195.tar.bz2 |
linux_aura: Closing a parent window should close child windows.
Unlike the Windows port, we need to manually keep track of relationships
between X windows so that we can close all windows marked as our
children before we close ourselves. This fixes a child destruction test.
BUG=300020
R=sky@chromium.org
Review URL: https://codereview.chromium.org/39733006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231635 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc | 31 | ||||
-rw-r--r-- | ui/views/widget/desktop_aura/desktop_root_window_host_x11.h | 5 | ||||
-rw-r--r-- | ui/views/widget/widget_unittest.cc | 4 |
3 files changed, 35 insertions, 5 deletions
diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc index 5f36446..180614e 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc @@ -123,7 +123,10 @@ DesktopRootWindowHostX11::DesktopRootWindowHostX11( drag_drop_client_(NULL), current_cursor_(ui::kCursorNull), native_widget_delegate_(native_widget_delegate), - desktop_native_widget_aura_(desktop_native_widget_aura) { + desktop_native_widget_aura_(desktop_native_widget_aura), + root_window_host_delegate_(NULL), + content_window_(NULL), + window_parent_(NULL) { } DesktopRootWindowHostX11::~DesktopRootWindowHostX11() { @@ -273,6 +276,22 @@ void DesktopRootWindowHostX11::CloseNow() { native_widget_delegate_->OnNativeWidgetDestroying(); + // If we have children, close them. Use a copy for iteration because they'll + // remove themselves. + std::set<DesktopRootWindowHostX11*> window_children_copy = window_children_; + for (std::set<DesktopRootWindowHostX11*>::iterator it = + window_children_copy.begin(); it != window_children_copy.end(); + ++it) { + (*it)->CloseNow(); + } + DCHECK(window_children_.empty()); + + // If we have a parent, remove ourselves from its children list. + if (window_parent_) { + window_parent_->window_children_.erase(this); + window_parent_ = NULL; + } + // Remove the event listeners we've installed. We need to remove these // because otherwise we get assert during ~RootWindow(). desktop_native_widget_aura_->root_window_event_filter()->RemoveHandler( @@ -971,6 +990,16 @@ void DesktopRootWindowHostX11::InitX11Window( ui::SetWindowClassHint( xdisplay_, xwindow_, params.wm_class_name, params.wm_class_class); } + + // If we have a parent, record the parent/child relationship. We use this + // data during destruction to make sure that when we try to close a parent + // window, we also destroy all child windows. + if (params.parent && params.parent->GetDispatcher()) { + XID parent_xid = params.parent->GetDispatcher()->GetAcceleratedWidget(); + window_parent_ = GetHostForXID(parent_xid); + DCHECK(window_parent_); + window_parent_->window_children_.insert(this); + } } bool DesktopRootWindowHostX11::IsWindowManagerPresent() { diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.h b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.h index e35dc36..19bc01c 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.h +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.h @@ -249,6 +249,11 @@ private: aura::RootWindowHostDelegate* root_window_host_delegate_; aura::Window* content_window_; + // We can optionally have a parent which can order us to close, or own + // children who we're responsible for closing when we CloseNow(). + DesktopRootWindowHostX11* window_parent_; + std::set<DesktopRootWindowHostX11*> window_children_; + ObserverList<DesktopRootWindowHostObserverX11> observer_list_; // The current root window host that has capture. While X11 has something diff --git a/ui/views/widget/widget_unittest.cc b/ui/views/widget/widget_unittest.cc index abdb000..67887b1 100644 --- a/ui/views/widget/widget_unittest.cc +++ b/ui/views/widget/widget_unittest.cc @@ -1958,9 +1958,6 @@ TEST_F(WidgetChildDestructionTest, RunDestroyChildWidgetsTest(true, false); } -// TODO: test fails on linux as destroying parent X widget does not -// automatically destroy transients. http://crbug.com/300020 . -#if !defined(OS_LINUX) // See description of RunDestroyChildWidgetsTest(). Both parent and child use // DesktopNativeWidgetAura. TEST_F(WidgetChildDestructionTest, @@ -1968,7 +1965,6 @@ TEST_F(WidgetChildDestructionTest, RunDestroyChildWidgetsTest(true, true); } #endif -#endif // See description of RunDestroyChildWidgetsTest(). TEST_F(WidgetChildDestructionTest, DestroyChildWidgetsInOrder) { |