Merge lp:~compiz-team/compiz/compiz.fix_1158267.update-tests into lp:compiz/0.9.11

Proposed by Sam Spilsbury
Status: Merged
Approved by: Francis Ginther
Approved revision: 3756
Merged at revision: 3787
Proposed branch: lp:~compiz-team/compiz/compiz.fix_1158267.update-tests
Merge into: lp:compiz/0.9.11
Diff against target: 448 lines (+259/-56)
3 files modified
plugins/decor/src/decor.cpp (+57/-48)
plugins/decor/tests/acceptance/xorg-gtest/CMakeLists.txt (+4/-2)
plugins/decor/tests/acceptance/xorg-gtest/compiz_decor_acceptance_tests.cpp (+198/-6)
To merge this branch: bzr merge lp:~compiz-team/compiz/compiz.fix_1158267.update-tests
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Christopher Townsend (community) Approve
Daniel van Vugt Pending
MC Return Pending
Review via email: mp+176801@code.launchpad.net

This proposal supersedes a proposal from 2013-07-22.

Commit message

Ensure that the frame region is always set as soon as the window is decorated.

Further ensure that the window decoration isn't needlessly reset if the
window already had one.

Refactored XShape usage into a common function.

Added tests to verify the behaviour of shape set on initially creating
a decorated window and also upon changing the input frame window shape

(LP: #1158267)

Description of the change

Ensure that the frame region is always set as soon as the window is decorated.

Further ensure that the window decoration isn't needlessly reset if the
window already had one.

Refactored XShape usage into a common function.

Added tests to verify the behaviour of shape set on initially creating
a decorated window and also upon changing the input frame window shape

(LP: #1158267)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

Have you seen bug #1203557 ?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

Running this does not seem to make things worse here, but as I am running Emerald, which is not supported and currently broken like never before I "Abstain" here.

review: Abstain
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

> Have you seen bug #1203557 ?

Yes, I have and I commented on it there. Please keep merge proposal discussions on-topic.

> Running this does not seem to make things worse here, but as I am running Emerald, which is not supported and currently broken like never before I "Abstain" here.

I would suggest switching to a supported window decorator if you wish to test these fixes.

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Please re-target to lp:compiz

review: Needs Resubmitting
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alberts Muktupāvels (muktupavels) wrote :

Why work on this have stopped?

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

I am no longer working on compiz.

Someone is free to take it over if they want.

Revision history for this message
Christopher Townsend (townsend) wrote :

This branch does fix the issue and so far, I've seen no regressions running this.

I'm approving this to get it in since so many people are affected by this. I'm also going to create a branch with this same fix for 0.9.10 so it gets into 13.10.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Francis Ginther (fginther) wrote :

Jenkins was misconfigured after the update. Config has been fixed, so re-approving.

Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/decor/src/decor.cpp'
--- plugins/decor/src/decor.cpp 2013-07-19 15:49:47 +0000
+++ plugins/decor/src/decor.cpp 2013-07-24 21:59:17 +0000
@@ -44,6 +44,34 @@
4444
45namespace cwe = compiz::window::extents;45namespace cwe = compiz::window::extents;
4646
47namespace
48{
49void updateRegionWithShapeRectangles (Display *dpy,
50 Window w,
51 CompRegion &region)
52{
53 int n = 0;
54 int order = 0;
55 XRectangle *shapeRects = NULL;
56
57 shapeRects =
58 XShapeGetRectangles (dpy,
59 w, ShapeInput,
60 &n, &order);
61 if (!shapeRects)
62 return;
63
64 for (int i = 0; i < n; i++)
65 region +=
66 CompRegion (shapeRects[i].x,
67 shapeRects[i].y,
68 shapeRects[i].width,
69 shapeRects[i].height);
70
71 XFree (shapeRects);
72}
73}
74
47MatchedDecorClipGroup::MatchedDecorClipGroup (const CompMatch &match) :75MatchedDecorClipGroup::MatchedDecorClipGroup (const CompMatch &match) :
48 mMatch (match)76 mMatch (match)
49{77{
@@ -1590,13 +1618,6 @@
1590 lastMaximizedStateDecorated == decorMaximizeState)1618 lastMaximizedStateDecorated == decorMaximizeState)
1591 return false;1619 return false;
15921620
1593 /* Destroy the old WindowDecoration */
1594 if (old)
1595 {
1596 WindowDecoration::destroy (wd);
1597 wd = NULL;
1598 }
1599
1600 /* If a decoration was found for this window, create1621 /* If a decoration was found for this window, create
1601 * a new WindowDecoration for it and set the frame1622 * a new WindowDecoration for it and set the frame
1602 * extents accordingly. We should also move the1623 * extents accordingly. We should also move the
@@ -1622,6 +1643,8 @@
1622 if (decorate ||1643 if (decorate ||
1623 shadowOnly)1644 shadowOnly)
1624 {1645 {
1646 if (wd)
1647 WindowDecoration::destroy (wd);
1625 wd = WindowDecoration::create (decoration);1648 wd = WindowDecoration::create (decoration);
1626 if (!wd)1649 if (!wd)
1627 {1650 {
@@ -1649,7 +1672,12 @@
1649 else1672 else
1650 {1673 {
1651 CompWindowExtents emptyExtents;1674 CompWindowExtents emptyExtents;
1652 wd = NULL;1675
1676 if (wd)
1677 {
1678 WindowDecoration::destroy (wd);
1679 wd = NULL;
1680 }
16531681
1654 /* _NET_FRAME_EXTENTS should be updated before the frame1682 /* _NET_FRAME_EXTENTS should be updated before the frame
1655 * atom is */1683 * atom is */
@@ -1903,6 +1931,13 @@
1903 ShapeSet, YXBanded);1931 ShapeSet, YXBanded);
19041932
1905 frameRegion = CompRegion ();1933 frameRegion = CompRegion ();
1934
1935 /* Immediately query shape rectangles so that we can
1936 * report them if core asks for them */
1937 updateRegionWithShapeRectangles (screen->dpy (),
1938 inputFrame,
1939 frameRegion);
1940 window->updateFrameRegion ();
1906 }1941 }
19071942
1908 XUngrabServer (screen->dpy ());1943 XUngrabServer (screen->dpy ());
@@ -2045,6 +2080,13 @@
2045 ShapeSet, YXBanded);2080 ShapeSet, YXBanded);
20462081
2047 frameRegion = CompRegion ();2082 frameRegion = CompRegion ();
2083
2084 /* Immediately query shape rectangles so that we can
2085 * report them if core asks for them */
2086 updateRegionWithShapeRectangles (screen->dpy (),
2087 outputFrame,
2088 frameRegion);
2089 window->updateFrameRegion ();
2048 }2090 }
20492091
2050 XUngrabServer (screen->dpy ());2092 XUngrabServer (screen->dpy ());
@@ -2168,6 +2210,7 @@
2168DecorWindow::updateFrameRegion (CompRegion &region)2210DecorWindow::updateFrameRegion (CompRegion &region)
2169{2211{
2170 window->updateFrameRegion (region);2212 window->updateFrameRegion (region);
2213
2171 if (wd)2214 if (wd)
2172 {2215 {
2173 if (!frameRegion.isEmpty ())2216 if (!frameRegion.isEmpty ())
@@ -2180,10 +2223,6 @@
2180 region += frameRegion.translated (x - wd->decor->input.left,2223 region += frameRegion.translated (x - wd->decor->input.left,
2181 y - wd->decor->input.top);2224 y - wd->decor->input.top);
2182 }2225 }
2183 else
2184 {
2185 region += infiniteRegion;
2186 }
2187 }2226 }
21882227
2189 updateReg = true;2228 updateReg = true;
@@ -2602,54 +2641,24 @@
2602 if (dw->inputFrame ==2641 if (dw->inputFrame ==
2603 ((XShapeEvent *) event)->window)2642 ((XShapeEvent *) event)->window)
2604 {2643 {
2605 XRectangle *shapeRects = 0;
2606 int order, n;
2607
2608 dw->frameRegion = CompRegion ();2644 dw->frameRegion = CompRegion ();
26092645
2610 shapeRects =2646 updateRegionWithShapeRectangles (screen->dpy (),
2611 XShapeGetRectangles (screen->dpy (),2647 dw->inputFrame,
2612 dw->inputFrame, ShapeInput,2648 dw->frameRegion);
2613 &n, &order);
2614 if (!shapeRects || !n)
2615 break;
2616
2617 for (int i = 0; i < n; i++)
2618 dw->frameRegion +=
2619 CompRegion (shapeRects[i].x,
2620 shapeRects[i].y,
2621 shapeRects[i].width,
2622 shapeRects[i].height);
26232649
2624 w->updateFrameRegion ();2650 w->updateFrameRegion ();
2625
2626 XFree (shapeRects);
2627 }2651 }
2628 else if (dw->outputFrame ==2652 else if (dw->outputFrame ==
2629 ((XShapeEvent *) event)->window)2653 ((XShapeEvent *) event)->window)
2630 {2654 {
2631 XRectangle *shapeRects = 0;
2632 int order, n;
2633
2634 dw->frameRegion = CompRegion ();2655 dw->frameRegion = CompRegion ();
26352656
2636 shapeRects =2657 updateRegionWithShapeRectangles (screen->dpy (),
2637 XShapeGetRectangles (screen->dpy (),2658 dw->outputFrame,
2638 dw->outputFrame, ShapeBounding,2659 dw->frameRegion);
2639 &n, &order);
2640 if (!n || !shapeRects)
2641 break;
2642
2643 for (int i = 0; i < n; i++)
2644 dw->frameRegion +=
2645 CompRegion (shapeRects[i].x,
2646 shapeRects[i].y,
2647 shapeRects[i].width,
2648 shapeRects[i].height);
26492660
2650 w->updateFrameRegion ();2661 w->updateFrameRegion ();
2651
2652 XFree (shapeRects);
2653 }2662 }
2654 }2663 }
2655 }2664 }
26562665
=== modified file 'plugins/decor/tests/acceptance/xorg-gtest/CMakeLists.txt'
--- plugins/decor/tests/acceptance/xorg-gtest/CMakeLists.txt 2013-07-15 20:11:19 +0000
+++ plugins/decor/tests/acceptance/xorg-gtest/CMakeLists.txt 2013-07-24 21:59:17 +0000
@@ -1,6 +1,8 @@
1include (FindPkgConfig)1include (FindPkgConfig)
22
3if (BUILD_XORG_GTEST)3pkg_check_modules (X11_XI x11 xi xext)
4
5if (BUILD_XORG_GTEST AND X11_XI_FOUND)
46
5 include_directories (${compiz_SOURCE_DIR}/tests/shared7 include_directories (${compiz_SOURCE_DIR}/tests/shared
6 ${COMPIZ_XORG_SYSTEM_TEST_INCLUDE_DIR}8 ${COMPIZ_XORG_SYSTEM_TEST_INCLUDE_DIR}
@@ -35,5 +37,5 @@
35 # Disabled until the tests can be run without opengl37 # Disabled until the tests can be run without opengl
36 #compiz_discover_tests (compiz_test_decor_acceptance WITH_XORG_GTEST)38 #compiz_discover_tests (compiz_test_decor_acceptance WITH_XORG_GTEST)
3739
38endif (BUILD_XORG_GTEST)40endif (BUILD_XORG_GTEST AND X11_XI_FOUND)
3941
4042
=== modified file 'plugins/decor/tests/acceptance/xorg-gtest/compiz_decor_acceptance_tests.cpp'
--- plugins/decor/tests/acceptance/xorg-gtest/compiz_decor_acceptance_tests.cpp 2013-07-19 19:17:31 +0000
+++ plugins/decor/tests/acceptance/xorg-gtest/compiz_decor_acceptance_tests.cpp 2013-07-24 21:59:17 +0000
@@ -33,6 +33,7 @@
3333
34#include <X11/Xlib.h>34#include <X11/Xlib.h>
35#include <X11/Xatom.h>35#include <X11/Xatom.h>
36#include <X11/extensions/shape.h>
3637
37#include "decoration.h"38#include "decoration.h"
3839
@@ -48,7 +49,10 @@
48namespace xt = xorg::testing;49namespace xt = xorg::testing;
49namespace ct = compiz::testing;50namespace ct = compiz::testing;
5051
52using ::testing::AllOf;
51using ::testing::AtLeast;53using ::testing::AtLeast;
54using ::testing::Eq;
55using ::testing::Field;
52using ::testing::ReturnNull;56using ::testing::ReturnNull;
53using ::testing::Return;57using ::testing::Return;
54using ::testing::MatcherInterface;58using ::testing::MatcherInterface;
@@ -1208,6 +1212,17 @@
1208 return parent;1212 return parent;
1209}1213}
12101214
1215bool WaitForReparent (::Display *dpy,
1216 Window w)
1217{
1218 return Advance (dpy,
1219 ct::WaitForEventOfTypeOnWindow (dpy,
1220 w,
1221 ReparentNotify,
1222 -1,
1223 -1));
1224}
1225
1211void FreeWindowArray (Window *array)1226void FreeWindowArray (Window *array)
1212{1227{
1213 if (array)1228 if (array)
@@ -1667,6 +1682,188 @@
1667 inputExtents));1682 inputExtents));
1668}1683}
16691684
1685class DecorPixmapShapeSetAcceptance :
1686 public DecorWithPixmapDefaultsAcceptance
1687{
1688 public:
1689
1690 virtual void SetUp ();
1691
1692 protected:
1693
1694 int shapeEvent;
1695 int shapeError;
1696
1697 int shapeMajor;
1698 int shapeMinor;
1699};
1700
1701void
1702DecorPixmapShapeSetAcceptance::SetUp ()
1703{
1704 DecorWithPixmapDefaultsAcceptance::SetUp ();
1705
1706 if (!XShapeQueryVersion (Display (), &shapeMajor, &shapeMinor))
1707 throw std::runtime_error ("Unable to query shape extension version");
1708
1709 if (!XShapeQueryExtension (Display (), &shapeEvent, &shapeError))
1710 throw std::runtime_error ("Unable to initialize shape extension");
1711}
1712
1713std::ostream &
1714operator<< (std::ostream &os, const XRectangle &r)
1715{
1716 os << "XRectangle: "
1717 << " x: " << r.x
1718 << " y: " << r.y
1719 << " width: " << r.width
1720 << " height: " << r.height;
1721
1722 return os;
1723}
1724
1725namespace
1726{
1727void FreeXRectangleArray (XRectangle *array)
1728{
1729 XFree (array);
1730}
1731
1732boost::shared_array <XRectangle>
1733ShapeRectangles (::Display *dpy,
1734 Window w,
1735 int &n,
1736 int &order)
1737{
1738 XRectangle *rects = XShapeGetRectangles(dpy,
1739 w,
1740 ShapeInput,
1741 &n,
1742 &order);
1743
1744 return boost::shared_array <XRectangle> (rects,
1745 boost::bind (FreeXRectangleArray,
1746 _1));
1747}
1748}
1749
1750TEST_F (DecorPixmapShapeSetAcceptance, FrameWindowHasInitialFullShape)
1751{
1752 Window w = ct::CreateNormalWindow (Display ());
1753
1754 RecievePropertyNotifyEvents (Display (), w);
1755 XMapRaised (Display (), w);
1756 WaitForPropertyNotify (Display (), w, "_NET_FRAME_EXTENTS");
1757
1758 Window parent = FindParent (Display (), w);
1759
1760 int x, y;
1761 unsigned int width, height, border;
1762
1763 ct::AbsoluteWindowGeometry (Display (),
1764 parent,
1765 x,
1766 y,
1767 width,
1768 height,
1769 border);
1770
1771 int n, order;
1772 boost::shared_array <XRectangle> rects (ShapeRectangles (Display (),
1773 parent,
1774 n,
1775 order));
1776
1777 ASSERT_THAT (n, Eq (1));
1778 EXPECT_THAT (rects[0],
1779 AllOf (Field (&XRectangle::x, Eq (0)),
1780 Field (&XRectangle::y, Eq (0)),
1781 Field (&XRectangle::width, Eq (width)),
1782 Field (&XRectangle::height, Eq (height))));
1783}
1784
1785TEST_F (DecorPixmapShapeSetAcceptance, FrameWindowShapeIsUpdated)
1786{
1787 Window w = ct::CreateNormalWindow (Display ());
1788
1789 RecievePropertyNotifyEvents (Display (), w);
1790 XMapRaised (Display (), w);
1791 WaitForReparent (Display (), w);
1792 WaitForPropertyNotify (Display (), w, DECOR_INPUT_FRAME_ATOM_NAME);
1793
1794 Window parent = FindParent (Display (), w);
1795
1796 int clientX, clientY;
1797 unsigned int clientWidth, clientHeight, border;
1798
1799 ct::AbsoluteWindowGeometry (Display (),
1800 w,
1801 clientX,
1802 clientY,
1803 clientWidth,
1804 clientHeight,
1805 border);
1806
1807 /* Get the input frame remove its input shape completely */
1808 boost::shared_ptr <unsigned char> inputFramePropertyData;
1809 FetchAndVerifyProperty (Display (),
1810 w,
1811 mDecorationInputFrameAtom,
1812 XA_WINDOW,
1813 32,
1814 1,
1815 0L,
1816 inputFramePropertyData);
1817
1818 Window inputFrame = *(reinterpret_cast <Window *> (inputFramePropertyData.get ()));
1819
1820 /* Sync first, and then combine rectangles on the input frame */
1821 XSync (Display (), false);
1822 XShapeSelectInput (Display (), parent, ShapeNotifyMask);
1823 XShapeCombineRectangles (Display (),
1824 inputFrame,
1825 ShapeInput,
1826 0,
1827 0,
1828 NULL,
1829 0,
1830 ShapeSet,
1831 0);
1832
1833 clientX += ActiveBorderExtent;
1834 clientY += ActiveBorderExtent;
1835
1836 /* Wait for a shape event on the frame window */
1837 ct::ShapeNotifyXEventMatcher matcher (ShapeInput,
1838 clientX,
1839 clientY,
1840 clientWidth,
1841 clientHeight,
1842 1);
1843 Advance (Display (),
1844 ct::WaitForEventOfTypeOnWindowMatching (Display (),
1845 parent,
1846 shapeEvent + ShapeNotify,
1847 -1,
1848 0,
1849 matcher));
1850
1851 /* Grab the shape rectangles of the parent, they should
1852 * be equal to the client window size */
1853 int n, order;
1854 boost::shared_array <XRectangle> rects (ShapeRectangles (Display (),
1855 parent,
1856 n,
1857 order));
1858
1859 ASSERT_THAT (n, Eq (1));
1860 EXPECT_THAT (rects[0],
1861 AllOf (Field (&XRectangle::x, Eq (clientX)),
1862 Field (&XRectangle::y, Eq (clientY)),
1863 Field (&XRectangle::width, Eq (clientWidth)),
1864 Field (&XRectangle::height, Eq (clientHeight))));
1865}
1866
1670/* TODO: Get bare decorations tests */1867/* TODO: Get bare decorations tests */
16711868
1672/* Helper class with some useful member functions */1869/* Helper class with some useful member functions */
@@ -1745,12 +1942,7 @@
1745 XMapRaised (display, window);1942 XMapRaised (display, window);
17461943
1747 /* Wait for the window to be reparented */1944 /* Wait for the window to be reparented */
1748 Advance (Display (),1945 WaitForReparent (display, window);
1749 ct::WaitForEventOfTypeOnWindow (display,
1750 window,
1751 ReparentNotify,
1752 -1,
1753 -1));
17541946
1755 /* Select for StructureNotify on the parent and wrapper1947 /* Select for StructureNotify on the parent and wrapper
1756 * windows */1948 * windows */

Subscribers

People subscribed via source and target branches

to all changes: