| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/widget/desktop_aura/x11_topmost_window_finder.h" | 5 #include "ui/views/widget/desktop_aura/x11_topmost_window_finder.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 #include <X11/extensions/shape.h> | 9 #include <X11/extensions/shape.h> |
| 10 #include <X11/Xlib.h> | 10 #include <X11/Xlib.h> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 : X11PropertyChangeWaiter(window, "_NET_WM_STATE") { | 44 : X11PropertyChangeWaiter(window, "_NET_WM_STATE") { |
| 45 const char* kAtomsToCache[] = { "_NET_WM_STATE_HIDDEN", NULL }; | 45 const char* kAtomsToCache[] = { "_NET_WM_STATE_HIDDEN", NULL }; |
| 46 atom_cache_.reset(new ui::X11AtomCache(gfx::GetXDisplay(), kAtomsToCache)); | 46 atom_cache_.reset(new ui::X11AtomCache(gfx::GetXDisplay(), kAtomsToCache)); |
| 47 } | 47 } |
| 48 | 48 |
| 49 virtual ~MinimizeWaiter() { | 49 virtual ~MinimizeWaiter() { |
| 50 } | 50 } |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 // X11PropertyChangeWaiter: | 53 // X11PropertyChangeWaiter: |
| 54 virtual bool ShouldKeepOnWaiting(const ui::PlatformEvent& event) OVERRIDE { | 54 virtual bool ShouldKeepOnWaiting(const ui::PlatformEvent& event) override { |
| 55 std::vector<Atom> wm_states; | 55 std::vector<Atom> wm_states; |
| 56 if (ui::GetAtomArrayProperty(xwindow(), "_NET_WM_STATE", &wm_states)) { | 56 if (ui::GetAtomArrayProperty(xwindow(), "_NET_WM_STATE", &wm_states)) { |
| 57 std::vector<Atom>::iterator it = std::find( | 57 std::vector<Atom>::iterator it = std::find( |
| 58 wm_states.begin(), | 58 wm_states.begin(), |
| 59 wm_states.end(), | 59 wm_states.end(), |
| 60 atom_cache_->GetAtom("_NET_WM_STATE_HIDDEN")); | 60 atom_cache_->GetAtom("_NET_WM_STATE_HIDDEN")); |
| 61 return it == wm_states.end(); | 61 return it == wm_states.end(); |
| 62 } | 62 } |
| 63 return true; | 63 return true; |
| 64 } | 64 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 75 StackingClientListWaiter(XID* expected_windows, size_t count) | 75 StackingClientListWaiter(XID* expected_windows, size_t count) |
| 76 : X11PropertyChangeWaiter(ui::GetX11RootWindow(), | 76 : X11PropertyChangeWaiter(ui::GetX11RootWindow(), |
| 77 "_NET_CLIENT_LIST_STACKING"), | 77 "_NET_CLIENT_LIST_STACKING"), |
| 78 expected_windows_(expected_windows, expected_windows + count) { | 78 expected_windows_(expected_windows, expected_windows + count) { |
| 79 } | 79 } |
| 80 | 80 |
| 81 virtual ~StackingClientListWaiter() { | 81 virtual ~StackingClientListWaiter() { |
| 82 } | 82 } |
| 83 | 83 |
| 84 // X11PropertyChangeWaiter: | 84 // X11PropertyChangeWaiter: |
| 85 virtual void Wait() OVERRIDE { | 85 virtual void Wait() override { |
| 86 // StackingClientListWaiter may be created after | 86 // StackingClientListWaiter may be created after |
| 87 // _NET_CLIENT_LIST_STACKING already contains |expected_windows|. | 87 // _NET_CLIENT_LIST_STACKING already contains |expected_windows|. |
| 88 if (!ShouldKeepOnWaiting(NULL)) | 88 if (!ShouldKeepOnWaiting(NULL)) |
| 89 return; | 89 return; |
| 90 | 90 |
| 91 X11PropertyChangeWaiter::Wait(); | 91 X11PropertyChangeWaiter::Wait(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 private: | 94 private: |
| 95 // X11PropertyChangeWaiter: | 95 // X11PropertyChangeWaiter: |
| 96 virtual bool ShouldKeepOnWaiting(const ui::PlatformEvent& event) OVERRIDE { | 96 virtual bool ShouldKeepOnWaiting(const ui::PlatformEvent& event) override { |
| 97 std::vector<XID> stack; | 97 std::vector<XID> stack; |
| 98 ui::GetXWindowStack(ui::GetX11RootWindow(), &stack); | 98 ui::GetXWindowStack(ui::GetX11RootWindow(), &stack); |
| 99 for (size_t i = 0; i < expected_windows_.size(); ++i) { | 99 for (size_t i = 0; i < expected_windows_.size(); ++i) { |
| 100 std::vector<XID>::iterator it = std::find( | 100 std::vector<XID>::iterator it = std::find( |
| 101 stack.begin(), stack.end(), expected_windows_[i]); | 101 stack.begin(), stack.end(), expected_windows_[i]); |
| 102 if (it == stack.end()) | 102 if (it == stack.end()) |
| 103 return true; | 103 return true; |
| 104 } | 104 } |
| 105 return false; | 105 return false; |
| 106 } | 106 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 198 |
| 199 static void SetUpTestCase() { | 199 static void SetUpTestCase() { |
| 200 gfx::GLSurface::InitializeOneOffForTests(); | 200 gfx::GLSurface::InitializeOneOffForTests(); |
| 201 ui::RegisterPathProvider(); | 201 ui::RegisterPathProvider(); |
| 202 base::FilePath ui_test_pak_path; | 202 base::FilePath ui_test_pak_path; |
| 203 ASSERT_TRUE(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path)); | 203 ASSERT_TRUE(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path)); |
| 204 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path); | 204 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path); |
| 205 } | 205 } |
| 206 | 206 |
| 207 // ViewsTestBase: | 207 // ViewsTestBase: |
| 208 virtual void SetUp() OVERRIDE { | 208 virtual void SetUp() override { |
| 209 ViewsTestBase::SetUp(); | 209 ViewsTestBase::SetUp(); |
| 210 | 210 |
| 211 // Make X11 synchronous for our display connection. This does not force the | 211 // Make X11 synchronous for our display connection. This does not force the |
| 212 // window manager to behave synchronously. | 212 // window manager to behave synchronously. |
| 213 XSynchronize(xdisplay(), True); | 213 XSynchronize(xdisplay(), True); |
| 214 | 214 |
| 215 // Ensure that the X11DesktopHandler exists. The X11DesktopHandler is | 215 // Ensure that the X11DesktopHandler exists. The X11DesktopHandler is |
| 216 // necessary to properly track menu windows. | 216 // necessary to properly track menu windows. |
| 217 X11DesktopHandler::get(); | 217 X11DesktopHandler::get(); |
| 218 } | 218 } |
| 219 | 219 |
| 220 virtual void TearDown() OVERRIDE { | 220 virtual void TearDown() override { |
| 221 XSynchronize(xdisplay(), False); | 221 XSynchronize(xdisplay(), False); |
| 222 ViewsTestBase::TearDown(); | 222 ViewsTestBase::TearDown(); |
| 223 } | 223 } |
| 224 | 224 |
| 225 private: | 225 private: |
| 226 DISALLOW_COPY_AND_ASSIGN(X11TopmostWindowFinderTest); | 226 DISALLOW_COPY_AND_ASSIGN(X11TopmostWindowFinderTest); |
| 227 }; | 227 }; |
| 228 | 228 |
| 229 TEST_F(X11TopmostWindowFinderTest, Basic) { | 229 TEST_F(X11TopmostWindowFinderTest, Basic) { |
| 230 // Avoid positioning test windows at 0x0 because window managers often have a | 230 // Avoid positioning test windows at 0x0 because window managers often have a |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 | 437 |
| 438 EXPECT_EQ(xid, FindTopmostXWindowAt(110, 110)); | 438 EXPECT_EQ(xid, FindTopmostXWindowAt(110, 110)); |
| 439 EXPECT_EQ(menu_xid, FindTopmostXWindowAt(150, 120)); | 439 EXPECT_EQ(menu_xid, FindTopmostXWindowAt(150, 120)); |
| 440 EXPECT_EQ(menu_xid, FindTopmostXWindowAt(210, 120)); | 440 EXPECT_EQ(menu_xid, FindTopmostXWindowAt(210, 120)); |
| 441 | 441 |
| 442 XDestroyWindow(xdisplay(), xid); | 442 XDestroyWindow(xdisplay(), xid); |
| 443 XDestroyWindow(xdisplay(), menu_xid); | 443 XDestroyWindow(xdisplay(), menu_xid); |
| 444 } | 444 } |
| 445 | 445 |
| 446 } // namespace views | 446 } // namespace views |
| OLD | NEW |