| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include <X11/extensions/shape.h> | 7 #include <X11/extensions/shape.h> |
| 8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
| 9 | 9 |
| 10 // Get rid of X11 macros which conflict with gtest. | 10 // Get rid of X11 macros which conflict with gtest. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 NULL | 46 NULL |
| 47 }; | 47 }; |
| 48 atom_cache_.reset(new ui::X11AtomCache(gfx::GetXDisplay(), kAtomsToCache)); | 48 atom_cache_.reset(new ui::X11AtomCache(gfx::GetXDisplay(), kAtomsToCache)); |
| 49 } | 49 } |
| 50 | 50 |
| 51 virtual ~WMStateWaiter() { | 51 virtual ~WMStateWaiter() { |
| 52 } | 52 } |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 // X11PropertyChangeWaiter: | 55 // X11PropertyChangeWaiter: |
| 56 virtual bool ShouldKeepOnWaiting(const ui::PlatformEvent& event) OVERRIDE { | 56 virtual bool ShouldKeepOnWaiting(const ui::PlatformEvent& event) override { |
| 57 std::vector<Atom> hints; | 57 std::vector<Atom> hints; |
| 58 if (ui::GetAtomArrayProperty(xwindow(), "_NET_WM_STATE", &hints)) { | 58 if (ui::GetAtomArrayProperty(xwindow(), "_NET_WM_STATE", &hints)) { |
| 59 std::vector<Atom>::iterator it = std::find( | 59 std::vector<Atom>::iterator it = std::find( |
| 60 hints.begin(), | 60 hints.begin(), |
| 61 hints.end(), | 61 hints.end(), |
| 62 atom_cache_->GetAtom(hint_)); | 62 atom_cache_->GetAtom(hint_)); |
| 63 bool hint_set = (it != hints.end()); | 63 bool hint_set = (it != hints.end()); |
| 64 return hint_set != wait_till_set_; | 64 return hint_set != wait_till_set_; |
| 65 } | 65 } |
| 66 return true; | 66 return true; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 80 // A NonClientFrameView with a window mask with the bottom right corner cut out. | 80 // A NonClientFrameView with a window mask with the bottom right corner cut out. |
| 81 class ShapedNonClientFrameView : public NonClientFrameView { | 81 class ShapedNonClientFrameView : public NonClientFrameView { |
| 82 public: | 82 public: |
| 83 explicit ShapedNonClientFrameView() { | 83 explicit ShapedNonClientFrameView() { |
| 84 } | 84 } |
| 85 | 85 |
| 86 virtual ~ShapedNonClientFrameView() { | 86 virtual ~ShapedNonClientFrameView() { |
| 87 } | 87 } |
| 88 | 88 |
| 89 // NonClientFrameView: | 89 // NonClientFrameView: |
| 90 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE { | 90 virtual gfx::Rect GetBoundsForClientView() const override { |
| 91 return bounds(); | 91 return bounds(); |
| 92 } | 92 } |
| 93 virtual gfx::Rect GetWindowBoundsForClientBounds( | 93 virtual gfx::Rect GetWindowBoundsForClientBounds( |
| 94 const gfx::Rect& client_bounds) const OVERRIDE { | 94 const gfx::Rect& client_bounds) const override { |
| 95 return client_bounds; | 95 return client_bounds; |
| 96 } | 96 } |
| 97 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE { | 97 virtual int NonClientHitTest(const gfx::Point& point) override { |
| 98 return HTNOWHERE; | 98 return HTNOWHERE; |
| 99 } | 99 } |
| 100 virtual void GetWindowMask(const gfx::Size& size, | 100 virtual void GetWindowMask(const gfx::Size& size, |
| 101 gfx::Path* window_mask) OVERRIDE { | 101 gfx::Path* window_mask) override { |
| 102 int right = size.width(); | 102 int right = size.width(); |
| 103 int bottom = size.height(); | 103 int bottom = size.height(); |
| 104 | 104 |
| 105 window_mask->moveTo(0, 0); | 105 window_mask->moveTo(0, 0); |
| 106 window_mask->lineTo(0, bottom); | 106 window_mask->lineTo(0, bottom); |
| 107 window_mask->lineTo(right, bottom); | 107 window_mask->lineTo(right, bottom); |
| 108 window_mask->lineTo(right, 10); | 108 window_mask->lineTo(right, 10); |
| 109 window_mask->lineTo(right - 10, 10); | 109 window_mask->lineTo(right - 10, 10); |
| 110 window_mask->lineTo(right - 10, 0); | 110 window_mask->lineTo(right - 10, 0); |
| 111 window_mask->close(); | 111 window_mask->close(); |
| 112 } | 112 } |
| 113 virtual void ResetWindowControls() OVERRIDE { | 113 virtual void ResetWindowControls() override { |
| 114 } | 114 } |
| 115 virtual void UpdateWindowIcon() OVERRIDE { | 115 virtual void UpdateWindowIcon() override { |
| 116 } | 116 } |
| 117 virtual void UpdateWindowTitle() OVERRIDE { | 117 virtual void UpdateWindowTitle() override { |
| 118 } | 118 } |
| 119 virtual void SizeConstraintsChanged() OVERRIDE { | 119 virtual void SizeConstraintsChanged() override { |
| 120 } | 120 } |
| 121 | 121 |
| 122 private: | 122 private: |
| 123 DISALLOW_COPY_AND_ASSIGN(ShapedNonClientFrameView); | 123 DISALLOW_COPY_AND_ASSIGN(ShapedNonClientFrameView); |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 class ShapedWidgetDelegate : public WidgetDelegateView { | 126 class ShapedWidgetDelegate : public WidgetDelegateView { |
| 127 public: | 127 public: |
| 128 ShapedWidgetDelegate() { | 128 ShapedWidgetDelegate() { |
| 129 } | 129 } |
| 130 | 130 |
| 131 virtual ~ShapedWidgetDelegate() { | 131 virtual ~ShapedWidgetDelegate() { |
| 132 } | 132 } |
| 133 | 133 |
| 134 // WidgetDelegateView: | 134 // WidgetDelegateView: |
| 135 virtual NonClientFrameView* CreateNonClientFrameView( | 135 virtual NonClientFrameView* CreateNonClientFrameView( |
| 136 Widget* widget) OVERRIDE { | 136 Widget* widget) override { |
| 137 return new ShapedNonClientFrameView; | 137 return new ShapedNonClientFrameView; |
| 138 } | 138 } |
| 139 | 139 |
| 140 private: | 140 private: |
| 141 DISALLOW_COPY_AND_ASSIGN(ShapedWidgetDelegate); | 141 DISALLOW_COPY_AND_ASSIGN(ShapedWidgetDelegate); |
| 142 }; | 142 }; |
| 143 | 143 |
| 144 // Creates a widget of size 100x100. | 144 // Creates a widget of size 100x100. |
| 145 scoped_ptr<Widget> CreateWidget(WidgetDelegate* delegate) { | 145 scoped_ptr<Widget> CreateWidget(WidgetDelegate* delegate) { |
| 146 scoped_ptr<Widget> widget(new Widget); | 146 scoped_ptr<Widget> widget(new Widget); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 191 |
| 192 } // namespace | 192 } // namespace |
| 193 | 193 |
| 194 class DesktopWindowTreeHostX11Test : public ViewsTestBase { | 194 class DesktopWindowTreeHostX11Test : public ViewsTestBase { |
| 195 public: | 195 public: |
| 196 DesktopWindowTreeHostX11Test() { | 196 DesktopWindowTreeHostX11Test() { |
| 197 } | 197 } |
| 198 virtual ~DesktopWindowTreeHostX11Test() { | 198 virtual ~DesktopWindowTreeHostX11Test() { |
| 199 } | 199 } |
| 200 | 200 |
| 201 virtual void SetUp() OVERRIDE { | 201 virtual void SetUp() override { |
| 202 ViewsTestBase::SetUp(); | 202 ViewsTestBase::SetUp(); |
| 203 | 203 |
| 204 // Make X11 synchronous for our display connection. This does not force the | 204 // Make X11 synchronous for our display connection. This does not force the |
| 205 // window manager to behave synchronously. | 205 // window manager to behave synchronously. |
| 206 XSynchronize(gfx::GetXDisplay(), True); | 206 XSynchronize(gfx::GetXDisplay(), True); |
| 207 } | 207 } |
| 208 | 208 |
| 209 virtual void TearDown() OVERRIDE { | 209 virtual void TearDown() override { |
| 210 XSynchronize(gfx::GetXDisplay(), False); | 210 XSynchronize(gfx::GetXDisplay(), False); |
| 211 ViewsTestBase::TearDown(); | 211 ViewsTestBase::TearDown(); |
| 212 } | 212 } |
| 213 | 213 |
| 214 private: | 214 private: |
| 215 DISALLOW_COPY_AND_ASSIGN(DesktopWindowTreeHostX11Test); | 215 DISALLOW_COPY_AND_ASSIGN(DesktopWindowTreeHostX11Test); |
| 216 }; | 216 }; |
| 217 | 217 |
| 218 // Tests that the shape is properly set on the x window. | 218 // Tests that the shape is properly set on the x window. |
| 219 TEST_F(DesktopWindowTreeHostX11Test, Shape) { | 219 TEST_F(DesktopWindowTreeHostX11Test, Shape) { |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 SubstructureRedirectMask | SubstructureNotifyMask, | 452 SubstructureRedirectMask | SubstructureNotifyMask, |
| 453 &xevent); | 453 &xevent); |
| 454 | 454 |
| 455 WMStateWaiter waiter(xid, "_NET_WM_STATE_FOCUSED", true); | 455 WMStateWaiter waiter(xid, "_NET_WM_STATE_FOCUSED", true); |
| 456 waiter.Wait(); | 456 waiter.Wait(); |
| 457 } | 457 } |
| 458 EXPECT_TRUE(widget.GetNativeWindow()->IsVisible()); | 458 EXPECT_TRUE(widget.GetNativeWindow()->IsVisible()); |
| 459 } | 459 } |
| 460 | 460 |
| 461 } // namespace views | 461 } // namespace views |
| OLD | NEW |