| 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 <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
| 8 #include <X11/Xregion.h> | 8 #include <X11/Xregion.h> |
| 9 #include <X11/extensions/shape.h> | 9 #include <X11/extensions/shape.h> |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| 11 | 11 |
| 12 #include <algorithm> | 12 #include <algorithm> |
| 13 #include <memory> | 13 #include <memory> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 // Get rid of X11 macros which conflict with gtest. | 16 // Get rid of X11 macros which conflict with gtest. |
| 17 #undef Bool | 17 #undef Bool |
| 18 #undef None | 18 #undef None |
| 19 | 19 |
| 20 #include "base/macros.h" | 20 #include "base/macros.h" |
| 21 #include "base/memory/ptr_util.h" | 21 #include "base/memory/ptr_util.h" |
| 22 #include "third_party/skia/include/core/SkRect.h" | 22 #include "third_party/skia/include/core/SkRect.h" |
| 23 #include "third_party/skia/include/core/SkRegion.h" | 23 #include "third_party/skia/include/core/SkRegion.h" |
| 24 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" |
| 25 #include "ui/aura/window_tree_host.h" | 25 #include "ui/aura/window_tree_host.h" |
| 26 #include "ui/events/platform/x11/x11_event_source.h" | 26 #include "ui/events/platform/x11/x11_event_source.h" |
| 27 #include "ui/gfx/path.h" | 27 #include "ui/gfx/path.h" |
| 28 #include "ui/gfx/path_x11.h" | 28 #include "ui/gfx/path_x11.h" |
| 29 #include "ui/gfx/x/x11_atom_cache.h" |
| 29 #include "ui/views/test/views_interactive_ui_test_base.h" | 30 #include "ui/views/test/views_interactive_ui_test_base.h" |
| 30 #include "ui/views/test/x11_property_change_waiter.h" | 31 #include "ui/views/test/x11_property_change_waiter.h" |
| 31 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 32 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 32 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" | 33 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" |
| 33 #include "ui/views/widget/widget.h" | 34 #include "ui/views/widget/widget.h" |
| 34 | 35 |
| 35 namespace views { | 36 namespace views { |
| 36 | 37 |
| 37 namespace { | 38 namespace { |
| 38 | 39 |
| 39 // Waits till |window| is minimized. | 40 // Waits till |window| is minimized. |
| 40 class MinimizeWaiter : public X11PropertyChangeWaiter { | 41 class MinimizeWaiter : public X11PropertyChangeWaiter { |
| 41 public: | 42 public: |
| 42 explicit MinimizeWaiter(XID window) | 43 explicit MinimizeWaiter(XID window) |
| 43 : X11PropertyChangeWaiter(window, "_NET_WM_STATE") {} | 44 : X11PropertyChangeWaiter(window, "_NET_WM_STATE") {} |
| 44 | 45 |
| 45 ~MinimizeWaiter() override {} | 46 ~MinimizeWaiter() override {} |
| 46 | 47 |
| 47 private: | 48 private: |
| 48 // X11PropertyChangeWaiter: | 49 // X11PropertyChangeWaiter: |
| 49 bool ShouldKeepOnWaiting(const ui::PlatformEvent& event) override { | 50 bool ShouldKeepOnWaiting(const ui::PlatformEvent& event) override { |
| 50 std::vector<Atom> wm_states; | 51 std::vector<Atom> wm_states; |
| 51 if (ui::GetAtomArrayProperty(xwindow(), "_NET_WM_STATE", &wm_states)) { | 52 if (ui::GetAtomArrayProperty(xwindow(), "_NET_WM_STATE", &wm_states)) { |
| 52 auto it = std::find(wm_states.cbegin(), wm_states.cend(), | 53 auto it = std::find(wm_states.cbegin(), wm_states.cend(), |
| 53 ui::GetAtom("_NET_WM_STATE_HIDDEN")); | 54 gfx::GetAtom("_NET_WM_STATE_HIDDEN")); |
| 54 return it == wm_states.cend(); | 55 return it == wm_states.cend(); |
| 55 } | 56 } |
| 56 return true; | 57 return true; |
| 57 } | 58 } |
| 58 | 59 |
| 59 DISALLOW_COPY_AND_ASSIGN(MinimizeWaiter); | 60 DISALLOW_COPY_AND_ASSIGN(MinimizeWaiter); |
| 60 }; | 61 }; |
| 61 | 62 |
| 62 // Waits till |_NET_CLIENT_LIST_STACKING| is updated to include | 63 // Waits till |_NET_CLIENT_LIST_STACKING| is updated to include |
| 63 // |expected_windows|. | 64 // |expected_windows|. |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 root, | 389 root, |
| 389 0, 0, 1, 1, | 390 0, 0, 1, 1, |
| 390 0, // border width | 391 0, // border width |
| 391 CopyFromParent, // depth | 392 CopyFromParent, // depth |
| 392 InputOutput, | 393 InputOutput, |
| 393 CopyFromParent, // visual | 394 CopyFromParent, // visual |
| 394 CWOverrideRedirect, | 395 CWOverrideRedirect, |
| 395 &swa); | 396 &swa); |
| 396 { | 397 { |
| 397 ui::SetAtomProperty(menu_xid, "_NET_WM_WINDOW_TYPE", "ATOM", | 398 ui::SetAtomProperty(menu_xid, "_NET_WM_WINDOW_TYPE", "ATOM", |
| 398 ui::GetAtom("_NET_WM_WINDOW_TYPE_MENU")); | 399 gfx::GetAtom("_NET_WM_WINDOW_TYPE_MENU")); |
| 399 } | 400 } |
| 400 ui::SetUseOSWindowFrame(menu_xid, false); | 401 ui::SetUseOSWindowFrame(menu_xid, false); |
| 401 ShowAndSetXWindowBounds(menu_xid, gfx::Rect(140, 110, 100, 100)); | 402 ShowAndSetXWindowBounds(menu_xid, gfx::Rect(140, 110, 100, 100)); |
| 402 ui::X11EventSource::GetInstance()->DispatchXEvents(); | 403 ui::X11EventSource::GetInstance()->DispatchXEvents(); |
| 403 | 404 |
| 404 // |menu_xid| is never added to _NET_CLIENT_LIST_STACKING. | 405 // |menu_xid| is never added to _NET_CLIENT_LIST_STACKING. |
| 405 XID xids[] = { xid }; | 406 XID xids[] = { xid }; |
| 406 StackingClientListWaiter stack_waiter(xids, arraysize(xids)); | 407 StackingClientListWaiter stack_waiter(xids, arraysize(xids)); |
| 407 stack_waiter.Wait(); | 408 stack_waiter.Wait(); |
| 408 | 409 |
| 409 EXPECT_EQ(xid, FindTopmostXWindowAt(110, 110)); | 410 EXPECT_EQ(xid, FindTopmostXWindowAt(110, 110)); |
| 410 EXPECT_EQ(menu_xid, FindTopmostXWindowAt(150, 120)); | 411 EXPECT_EQ(menu_xid, FindTopmostXWindowAt(150, 120)); |
| 411 EXPECT_EQ(menu_xid, FindTopmostXWindowAt(210, 120)); | 412 EXPECT_EQ(menu_xid, FindTopmostXWindowAt(210, 120)); |
| 412 | 413 |
| 413 XDestroyWindow(xdisplay(), xid); | 414 XDestroyWindow(xdisplay(), xid); |
| 414 XDestroyWindow(xdisplay(), menu_xid); | 415 XDestroyWindow(xdisplay(), menu_xid); |
| 415 } | 416 } |
| 416 | 417 |
| 417 } // namespace views | 418 } // namespace views |
| OLD | NEW |