From cc7a66d49ed87b47fe9350c9eecb552f6d5d1a26 Mon Sep 17 00:00:00 2001 From: "mlamouri@chromium.org" Date: Thu, 23 Jan 2014 04:13:50 +0000 Subject: Fixes _NET_ACTIVE_WINDOW support check in order to not always return no. The check is currently not working on Unity because it expects an array of atoms instead of one XID. With this patch, Unity is correctly seen as supporting the feature. BUG=None Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=246270 Review URL: https://codereview.chromium.org/138903007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@246520 0039d316-1c4b-4281-b951-d872f2087c98 --- .../desktop_aura/desktop_screen_x11_unittest.cc | 4 ++++ .../widget/desktop_aura/x11_desktop_handler.cc | 25 ++++++++-------------- ui/views/widget/desktop_aura/x11_desktop_handler.h | 6 ++++++ 3 files changed, 19 insertions(+), 16 deletions(-) (limited to 'ui') diff --git a/ui/views/widget/desktop_aura/desktop_screen_x11_unittest.cc b/ui/views/widget/desktop_aura/desktop_screen_x11_unittest.cc index 3712ac3..69b6c6c 100644 --- a/ui/views/widget/desktop_aura/desktop_screen_x11_unittest.cc +++ b/ui/views/widget/desktop_aura/desktop_screen_x11_unittest.cc @@ -10,6 +10,7 @@ #include "ui/views/test/views_test_base.h" #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" #include "ui/views/widget/desktop_aura/desktop_root_window_host_x11.h" +#include "ui/views/widget/desktop_aura/x11_desktop_handler.h" namespace views { @@ -30,6 +31,9 @@ class DesktopScreenX11Test : public views::ViewsTestBase, displays.push_back(gfx::Display(kFirstDisplay, gfx::Rect(0, 0, 640, 480))); screen_.reset(new DesktopScreenX11(displays)); screen_->AddObserver(this); + + // We want to have a synchronous activation behavior. + X11DesktopHandler::get()->SetWMSupportsActiveWindowForTests(false); } virtual void TearDown() OVERRIDE { diff --git a/ui/views/widget/desktop_aura/x11_desktop_handler.cc b/ui/views/widget/desktop_aura/x11_desktop_handler.cc index 8125611..e754f74 100644 --- a/ui/views/widget/desktop_aura/x11_desktop_handler.cc +++ b/ui/views/widget/desktop_aura/x11_desktop_handler.cc @@ -55,17 +55,10 @@ X11DesktopHandler::X11DesktopHandler() attr.your_event_mask | PropertyChangeMask | StructureNotifyMask | SubstructureNotifyMask); - std::vector atoms; - if (ui::GetAtomArrayProperty(x_root_window_, "_NET_ACTIVE_WINDOW", &atoms)) { - Atom active_window = atom_cache_.GetAtom("_NET_ACTIVE_WINDOW"); - for (std::vector::iterator iter = atoms.begin(); iter != atoms.end(); - ++iter) { - if (*(iter) == active_window) { - wm_supports_active_window_ = true; - break; - } - } - } + ::Window active_window; + wm_supports_active_window_ = + ui::GetXIDProperty(x_root_window_, "_NET_ACTIVE_WINDOW", &active_window) && + active_window; } X11DesktopHandler::~X11DesktopHandler() { @@ -136,14 +129,14 @@ bool X11DesktopHandler::Dispatch(const base::NativeEvent& event) { // Check for a change to the active window. switch (event->type) { case PropertyNotify: { - ::Atom active_window = atom_cache_.GetAtom("_NET_ACTIVE_WINDOW"); + ::Atom active_window_atom = atom_cache_.GetAtom("_NET_ACTIVE_WINDOW"); if (event->xproperty.window == x_root_window_ && - event->xproperty.atom == active_window) { - int window; - if (ui::GetIntProperty(x_root_window_, "_NET_ACTIVE_WINDOW", &window) && + event->xproperty.atom == active_window_atom) { + ::Window window; + if (ui::GetXIDProperty(x_root_window_, "_NET_ACTIVE_WINDOW", &window) && window) { - OnActiveWindowChanged(static_cast< ::Window>(window)); + OnActiveWindowChanged(window); } } break; diff --git a/ui/views/widget/desktop_aura/x11_desktop_handler.h b/ui/views/widget/desktop_aura/x11_desktop_handler.h index 085a9e4..72651a3 100644 --- a/ui/views/widget/desktop_aura/x11_desktop_handler.h +++ b/ui/views/widget/desktop_aura/x11_desktop_handler.h @@ -51,6 +51,12 @@ class VIEWS_EXPORT X11DesktopHandler : public base::MessagePumpDispatcher, virtual void OnWindowInitialized(aura::Window* window) OVERRIDE; virtual void OnWillDestroyEnv() OVERRIDE; + // Allows to override wm_supports_active_window_ value for tests. If the WM + // supports _NET_ACTIVE_WINDOW, activation is async otherwise it is sync. + void SetWMSupportsActiveWindowForTests(bool value) { + wm_supports_active_window_ = value; + } + private: explicit X11DesktopHandler(); virtual ~X11DesktopHandler(); -- cgit v1.1