diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-05 18:11:21 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-05 18:11:21 +0000 |
commit | bac66d44105fec443fe88e39f0153fb3d75dab40 (patch) | |
tree | bafe71233adbb5e2c8c666d6623a0f047ae37525 /ui | |
parent | acb3b69cb8757f743475d8eebcecc1dbc0f59ccc (diff) | |
download | chromium_src-bac66d44105fec443fe88e39f0153fb3d75dab40.zip chromium_src-bac66d44105fec443fe88e39f0153fb3d75dab40.tar.gz chromium_src-bac66d44105fec443fe88e39f0153fb3d75dab40.tar.bz2 |
Aura/ash split: Desktop linux clients should respsect window manager close window events.
BUG=121725
TEST=none
Review URL: https://chromiumcodereview.appspot.com/9969126
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130971 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/aura/root_window.cc | 5 | ||||
-rw-r--r-- | ui/aura/root_window.h | 3 | ||||
-rw-r--r-- | ui/aura/root_window_host_linux.cc | 18 | ||||
-rw-r--r-- | ui/aura/root_window_host_linux.h | 3 | ||||
-rw-r--r-- | ui/aura/root_window_observer.h | 4 | ||||
-rw-r--r-- | ui/views/widget/native_widget_aura.cc | 8 | ||||
-rw-r--r-- | ui/views/widget/native_widget_aura.h | 5 |
7 files changed, 46 insertions, 0 deletions
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc index 99e1ad0..188c77c 100644 --- a/ui/aura/root_window.cc +++ b/ui/aura/root_window.cc @@ -360,6 +360,11 @@ void RootWindow::OnKeyboardMappingChanged() { OnKeyboardMappingChanged(this)); } +void RootWindow::OnRootWindowHostClosed() { + FOR_EACH_OBSERVER(RootWindowObserver, observers_, + OnRootWindowHostClosed(this)); +} + void RootWindow::AddRootWindowObserver(RootWindowObserver* observer) { observers_.AddObserver(observer); } diff --git a/ui/aura/root_window.h b/ui/aura/root_window.h index 896af44..a08fe05 100644 --- a/ui/aura/root_window.h +++ b/ui/aura/root_window.h @@ -166,6 +166,9 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate, // keycodes and keysyms) has changed. void OnKeyboardMappingChanged(); + // The system windowing system has sent a request that we close our window. + void OnRootWindowHostClosed(); + // Add/remove observer. There is no need to remove the observer if // the root window is being deleted. In particular, you SHOULD NOT remove // in |WindowObserver::OnWindowDestroying| of the observer observing diff --git a/ui/aura/root_window_host_linux.cc b/ui/aura/root_window_host_linux.cc index cd2597b..54e7505 100644 --- a/ui/aura/root_window_host_linux.cc +++ b/ui/aura/root_window_host_linux.cc @@ -326,6 +326,15 @@ RootWindowHostLinux::RootWindowHostLinux(const gfx::Rect& bounds) if (RootWindow::hide_host_cursor()) XDefineCursor(xdisplay_, x_root_window_, invisible_cursor_); + // TODO(erg): We currently only request window deletion events. We also + // should listen for activation events and anything else that GTK+ listens + // for, and do something useful. + wm_delete_window_atom_ = XInternAtom(xdisplay_, "WM_DELETE_WINDOW", False); + + ::Atom protocols[1]; + protocols[0] = wm_delete_window_atom_; + XSetWMProtocols(xdisplay_, xwindow_, protocols, 1); + // crbug.com/120229 - set the window title so gtalk can find the primary root // window to broadcast. // TODO(jhorwich) Remove this once Chrome supports window-based broadcasting. @@ -466,6 +475,15 @@ base::MessagePumpDispatcher::DispatchStatus RootWindowHostLinux::Dispatch( handled = true; break; } + case ClientMessage: { + Atom message_type = static_cast<Atom>(xev->xclient.data.l[0]); + if (message_type == wm_delete_window_atom_) { + // We have received a close message from the window manager. + root_window_->OnRootWindowHostClosed(); + handled = true; + } + break; + } case MappingNotify: { switch (xev->xmapping.request) { case MappingModifier: diff --git a/ui/aura/root_window_host_linux.h b/ui/aura/root_window_host_linux.h index 83f59c0..8db9efd 100644 --- a/ui/aura/root_window_host_linux.h +++ b/ui/aura/root_window_host_linux.h @@ -78,6 +78,9 @@ class RootWindowHostLinux : public RootWindowHost, // The bounds of |xwindow_|. gfx::Rect bounds_; + // Cached atom + ::Atom wm_delete_window_atom_; + // True if the window should be focused when the window is shown. bool focus_when_shown_; diff --git a/ui/aura/root_window_observer.h b/ui/aura/root_window_observer.h index 366b752..39c9a4a 100644 --- a/ui/aura/root_window_observer.h +++ b/ui/aura/root_window_observer.h @@ -22,6 +22,10 @@ class AURA_EXPORT RootWindowObserver { virtual void OnRootWindowResized(const RootWindow* root, const gfx::Size& old_size) {} + // Invoked when the native windowing system sends us a request to close our + // window. + virtual void OnRootWindowHostClosed(const RootWindow* root) {} + // Invoked when a window is focused. virtual void OnWindowFocused(Window* window) {} diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc index 116d6f1..8b27a13 100644 --- a/ui/views/widget/native_widget_aura.cc +++ b/ui/views/widget/native_widget_aura.cc @@ -179,6 +179,7 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { root_window_.reset(new aura::RootWindow(bounds)); root_window_->SetEventFilter( new aura::DesktopRootWindowEventFilter(root_window_.get())); + root_window_->AddRootWindowObserver(this); aura::client::SetActivationClient( root_window_.get(), @@ -814,6 +815,13 @@ void NativeWidgetAura::OnWindowVisibilityChanged(bool visible) { } //////////////////////////////////////////////////////////////////////////////// +// NativeWidgetAura, aura::RootWindowObserver implementation: + +void NativeWidgetAura::OnRootWindowHostClosed(const aura::RootWindow* root) { + GetWidget()->Close(); +} + +//////////////////////////////////////////////////////////////////////////////// // NativeWidgetAura, aura::ActivationDelegate implementation: bool NativeWidgetAura::ShouldActivate(const aura::Event* event) { diff --git a/ui/views/widget/native_widget_aura.h b/ui/views/widget/native_widget_aura.h index 2621918..4733c07 100644 --- a/ui/views/widget/native_widget_aura.h +++ b/ui/views/widget/native_widget_aura.h @@ -10,6 +10,7 @@ #include "base/memory/weak_ptr.h" #include "ui/aura/client/activation_delegate.h" #include "ui/aura/client/drag_drop_delegate.h" +#include "ui/aura/root_window_observer.h" #include "ui/aura/window_delegate.h" #include "ui/base/events.h" #include "ui/views/views_export.h" @@ -30,6 +31,7 @@ class TooltipManagerAura; class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate, public aura::WindowDelegate, + public aura::RootWindowObserver, public aura::client::ActivationDelegate, public aura::client::DragDropDelegate { public: @@ -149,6 +151,9 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate, virtual void OnWindowDestroyed() OVERRIDE; virtual void OnWindowVisibilityChanged(bool visible) OVERRIDE; + // Overridden from aura::RootWindowObserver: + virtual void OnRootWindowHostClosed(const aura::RootWindow* root) OVERRIDE; + // Overridden from aura::client::ActivationDelegate: virtual bool ShouldActivate(const aura::Event* event) OVERRIDE; virtual void OnActivated() OVERRIDE; |