Merge lp:~compiz-team/compiz/compiz.fix_1188900.1 into lp:compiz/0.9.10

Proposed by Sam Spilsbury
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 3744
Proposed branch: lp:~compiz-team/compiz/compiz.fix_1188900.1
Merge into: lp:compiz/0.9.10
Diff against target: 1383 lines (+808/-157)
5 files modified
plugins/decor/tests/acceptance/xorg-gtest/CMakeLists.txt (+2/-0)
plugins/decor/tests/acceptance/xorg-gtest/compiz_decor_acceptance_tests.cpp (+777/-132)
tests/system/xorg-gtest/tests/compiz_xorg_gtest_configure_window.cpp (+6/-25)
tests/xorg-gtest/include/compiz-xorg-gtest.h (+3/-0)
tests/xorg-gtest/src/compiz-xorg-gtest.cpp (+20/-0)
To merge this branch: bzr merge lp:~compiz-team/compiz/compiz.fix_1188900.1
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Andrea Azzarone Approve
Review via email: mp+170954@code.launchpad.net

Commit message

Add more acceptance tests for the decor plugin.

PixmapDecoratedWindowAcceptance.
  UndecoratedWindowExpandToOrigSize

    Test that upon undecoration, the window has exactly the same geometry
    as it did before decoration.

  DISABLED_UndecorateStaticGravityWindow

    Tests that for windows with a static gravity, the window has exactly
    the same geometry as it did before decoration.

    Disabled, as core is currently not moving the window with the static
    gravity back to where it started.

AdjustmentExtents/PixmapDecorationAdjustment.
  AdjustRestoredWindowBorderMovesClient/P

    Test that changing the border extents causes the client window's
    absolute geometry to change.

  DISABLED_AdjustRestoredWindowBorderShrinkClient/P

    Tests that changing the border extents causes the client window's
    absolute geometry to shrink by the amount of border.

    Disabled, as the current behavior is to expand the frame window
    as opposed to shrinking the client (but this will be changed).

  DISABLED_ClientExpandsAsBorderShrinks/P

    Tests that as the border shrinks away, the client expands back to
    its original size.

    Disabled, as the current behavior is to expand the frame window
    as opposed to shrinking the client (but this will be changed).

  DISABLED_ClientExpandsAsBorderShrinksWhilstMaximized/P

    Tests that even if the client is maximized, if the restored border
    shrinks away it demaximizes back to the same position while also
    accounting for any change in the restored window border size.

    Disabled, as the current behavior is to expand the frame window
    as opposed to shrinking the client (but this will be changed).

  DISABLED_ClientExpandsAsBorderShrinksWhilstUndecorated/P

    Tests that even when the client is not permitted to be decorated
    because the decoration hint was removed, when it is redecorated
    it will be moved to the correct position taking into account any
    changes in its border size.

    Disabled, as the current behavior is to expand the frame window
    as opposed to shrinking the client (but this will be changed).

  DISABLED_AdjustRestoredWindowInputNoMoveClient/P

    Tests that adjusting the input extents (as independent from the
    border extents) of the client does not cause the client to move.

    Disabled, as this behavior appears to be broken in core.

Move the "GetImmediateParent" function into the compiz::testing namespace
so that it can be used by other tests.

Description of the change

Add more acceptance tests for the decor plugin.

PixmapDecoratedWindowAcceptance.
  UndecoratedWindowExpandToOrigSize

    Test that upon undecoration, the window has exactly the same geometry
    as it did before decoration.

  DISABLED_UndecorateStaticGravityWindow

    Tests that for windows with a static gravity, the window has exactly
    the same geometry as it did before decoration.

    Disabled, as core is currently not moving the window with the static
    gravity back to where it started.

AdjustmentExtents/PixmapDecorationAdjustment.
  AdjustRestoredWindowBorderMovesClient/P

    Test that changing the border extents causes the client window's
    absolute geometry to change.

  DISABLED_AdjustRestoredWindowBorderShrinkClient/P

    Tests that changing the border extents causes the client window's
    absolute geometry to shrink by the amount of border.

    Disabled, as the current behavior is to expand the frame window
    as opposed to shrinking the client (but this will be changed).

  DISABLED_ClientExpandsAsBorderShrinks/P

    Tests that as the border shrinks away, the client expands back to
    its original size.

    Disabled, as the current behavior is to expand the frame window
    as opposed to shrinking the client (but this will be changed).

  DISABLED_ClientExpandsAsBorderShrinksWhilstMaximized/P

    Tests that even if the client is maximized, if the restored border
    shrinks away it demaximizes back to the same position while also
    accounting for any change in the restored window border size.

    Disabled, as the current behavior is to expand the frame window
    as opposed to shrinking the client (but this will be changed).

  DISABLED_ClientExpandsAsBorderShrinksWhilstUndecorated/P

    Tests that even when the client is not permitted to be decorated
    because the decoration hint was removed, when it is redecorated
    it will be moved to the correct position taking into account any
    changes in its border size.

    Disabled, as the current behavior is to expand the frame window
    as opposed to shrinking the client (but this will be changed).

  DISABLED_AdjustRestoredWindowInputNoMoveClient/P

    Tests that adjusting the input extents (as independent from the
    border extents) of the client does not cause the client to move.

    Disabled, as this behavior appears to be broken in core.

Move the "GetImmediateParent" function into the compiz::testing namespace
so that it can be used by other tests.

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

What are all those "/P"s in the commit message about ?

I think some word is missing in this comment (probably it is 'disabled'):

264 + /* The use of the timeout is currently because some functionality
265 + * is broken which would cause these barrier conditions to never
266 + * eventuate. For now just get to the fail condition */

187 + void DisallowDecorationsOnWindow (Window window);

Maybe ForbidDecorationsOnWindow (Window window); would be better ? You decide.

This comment could be a one-liner (ultraminor):

406 + /* Select for StructureNotify on the parent and wrapper
407 + * windows */

823 - unsigned int width, height, border, depth;
824 + unsigned int width, height, border;

Don't we need depth anymore ? A quick search in the code shows that it was not
really used, although windows should have a depth for advanced animations, no ?

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

On 23/06/2013 7:00 PM, "MC Return" <email address hidden> wrote:
>
> What are all those "/P"s in the commit message about ?

Just a demonstration that each test is parameterized (so its not repeated 4
times)
>
> I think some word is missing in this comment (probably it is 'disabled'):
>
> 264 + /* The use of the timeout is currently because some
functionality
> 265 + * is broken which would cause these barrier conditions to
never
> 266 + * eventuate. For now just get to the fail condition */

Thanks.

>
> 187 + void DisallowDecorationsOnWindow (Window window);
>
> Maybe ForbidDecorationsOnWindow (Window window); would be better ? You
decide.

That works too.
>
> This comment could be a one-liner (ultraminor):
>
> 406 + /* Select for StructureNotify on the parent and wrapper
> 407 + * windows */
>
> 823 - unsigned int width, height, border, depth;
> 824 + unsigned int width, height, border;
>
> Don't we need depth anymore ? A quick search in the code shows that it
was not
> really used, although windows should have a depth for advanced
animations, no ?

"Depth" as in bit depth . the variable was removed as I replaced
XGetGeometry usage with a wrapper function which doesn't return a value for
that variable as i don't care about it.

>
>
> --
>
https://code.launchpad.net/~compiz-team/compiz/compiz.fix_1188900.1/+merge/170954
> Your team Compiz Maintainers is requested to review the proposed merge of
lp:~compiz-team/compiz/compiz.fix_1188900.1 into lp:compiz.

3743. By Sam Spilsbury

Only mark for no further instantiations once we've finished destructing
the plugin

(LP: #1193596). Fixes: https://bugs.launchpad.net/bugs/1193596.

Approved by PS Jenkins bot, Sami Jaktholm, MC Return.

Revision history for this message
Andrea Azzarone (azzar1) wrote :

LGTM.

review: Approve
Revision history for this message
Andrea Azzarone (azzar1) wrote :

[----------] Global test environment tear-down
Server terminated successfully (0). Closing log file.
[==========] 25 tests from 5 test cases ran. (9944 ms total)
[ PASSED ] 25 tests.

  YOU HAVE 19 DISABLED TESTS

Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)
3744. By Sam Spilsbury

Add more acceptance tests for the decor plugin.

PixmapDecoratedWindowAcceptance.
  UndecoratedWindowExpandToOrigSize

    Test that upon undecoration, the window has exactly the same geometry
    as it did before decoration.

  DISABLED_UndecorateStaticGravityWindow

    Tests that for windows with a static gravity, the window has exactly
    the same geometry as it did before decoration.

    Disabled, as core is currently not moving the window with the static
    gravity back to where it started.

AdjustmentExtents/PixmapDecorationAdjustment.
  AdjustRestoredWindowBorderMovesClient/P

    Test that changing the border extents causes the client window's
    absolute geometry to change.

  DISABLED_AdjustRestoredWindowBorderShrinkClient/P

    Tests that changing the border extents causes the client window's
    absolute geometry to shrink by the amount of border.

    Disabled, as the current behavior is to expand the frame window
    as opposed to shrinking the client (but this will be changed).

  DISABLED_ClientExpandsAsBorderShrinks/P

    Tests that as the border shrinks away, the client expands back to
    its original size.

    Disabled, as the current behavior is to expand the frame window
    as opposed to shrinking the client (but this will be changed).

  DISABLED_ClientExpandsAsBorderShrinksWhilstMaximized/P

    Tests that even if the client is maximized, if the restored border
    shrinks away it demaximizes back to the same position while also
    accounting for any change in the restored window border size.

    Disabled, as the current behavior is to expand the frame window
    as opposed to shrinking the client (but this will be changed).

  DISABLED_ClientExpandsAsBorderShrinksWhilstUndecorated/P

    Tests that even when the client is not permitted to be decorated
    because the decoration hint was removed, when it is redecorated
    it will be moved to the correct position taking into account any
    changes in its border size.

    Disabled, as the current behavior is to expand the frame window
    as opposed to shrinking the client (but this will be changed).

  DISABLED_AdjustRestoredWindowInputNoMoveClient/P

    Tests that adjusting the input extents (as independent from the
    border extents) of the client does not cause the client to move.

    Disabled, as this behavior appears to be broken in core.

Move the "GetImmediateParent" function into the compiz::testing namespace
so that it can be used by other tests. Fixes: https://bugs.launchpad.net/bugs/1188900.

Approved by PS Jenkins bot, Andrea Azzarone.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/decor/tests/acceptance/xorg-gtest/CMakeLists.txt'
--- plugins/decor/tests/acceptance/xorg-gtest/CMakeLists.txt 2013-06-10 08:55:23 +0000
+++ plugins/decor/tests/acceptance/xorg-gtest/CMakeLists.txt 2013-06-22 14:36:23 +0000
@@ -20,6 +20,8 @@
20 compiz_xorg_gtest_main20 compiz_xorg_gtest_main
21 compiz_xorg_gtest_system_test21 compiz_xorg_gtest_system_test
22 decoration22 decoration
23 compiz_point
24 compiz_size
23 ${GMOCK_LIBRARY}25 ${GMOCK_LIBRARY}
24 ${GMOCK_MAIN_LIBRARY}26 ${GMOCK_MAIN_LIBRARY}
25 ${GTEST_BOTH_LIBRARIES}27 ${GTEST_BOTH_LIBRARIES}
2628
=== 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-06-15 03:52:41 +0000
+++ plugins/decor/tests/acceptance/xorg-gtest/compiz_decor_acceptance_tests.cpp 2013-06-22 14:36:23 +0000
@@ -36,6 +36,9 @@
3636
37#include "decoration.h"37#include "decoration.h"
3838
39#include <core/point.h>
40#include <core/size.h>
41
39#include <xorg/gtest/xorg-gtest.h>42#include <xorg/gtest/xorg-gtest.h>
40#include <compiz-xorg-gtest.h>43#include <compiz-xorg-gtest.h>
4144
@@ -50,6 +53,8 @@
50using ::testing::Matcher;53using ::testing::Matcher;
51using ::testing::MakeMatcher;54using ::testing::MakeMatcher;
52using ::testing::StrEq;55using ::testing::StrEq;
56using ::testing::ValuesIn;
57using ::testing::WithParamInterface;
53using ::testing::_;58using ::testing::_;
5459
55class BaseDecorAcceptance :60class BaseDecorAcceptance :
@@ -172,6 +177,15 @@
172const char *OtherDecorationManagerRunningMessage =177const char *OtherDecorationManagerRunningMessage =
173 "Another decoration manager is already running";178 "Another decoration manager is already running";
174179
180struct MWMHints
181{
182 unsigned long flags;
183 unsigned long functions;
184 unsigned long decorations;
185};
186
187static const unsigned int MwmDecor = 1L << 0;
188
175class FakeDecorator189class FakeDecorator
176{190{
177 public:191 public:
@@ -223,6 +237,9 @@
223 unsigned int state,237 unsigned int state,
224 unsigned int actions) const;238 unsigned int actions) const;
225239
240 virtual CompPoint restoredFrameWindowOffset () const = 0;
241 virtual CompSize restoredDecorationSize () const = 0;
242
226 protected:243 protected:
227244
228 void insertBaseData (std::vector <long> &) const;245 void insertBaseData (std::vector <long> &) const;
@@ -254,6 +271,8 @@
254271
255 size_t propertyDataSize () const;272 size_t propertyDataSize () const;
256 void addPropertyData (std::vector<long> &) const;273 void addPropertyData (std::vector<long> &) const;
274 CompPoint restoredFrameWindowOffset () const;
275 CompSize restoredDecorationSize () const;
257276
258 static const unsigned int WindowDecorationSize = 8;277 static const unsigned int WindowDecorationSize = 8;
259278
@@ -268,6 +287,8 @@
268{287{
269 public:288 public:
270289
290 typedef boost::shared_ptr <FakePixmapTypeDecoration> Ptr;
291
271 FakePixmapTypeDecoration (unsigned int type,292 FakePixmapTypeDecoration (unsigned int type,
272 unsigned int state,293 unsigned int state,
273 unsigned int actions,294 unsigned int actions,
@@ -280,6 +301,12 @@
280 Display *dpy);301 Display *dpy);
281 ~FakePixmapTypeDecoration ();302 ~FakePixmapTypeDecoration ();
282303
304 void changeRestoredBorder (const decor_extents_t &border);
305 void changeRestoredInput (const decor_extents_t &input);
306
307 CompPoint restoredFrameWindowOffset () const;
308 CompSize restoredDecorationSize () const;
309
283 protected:310 protected:
284311
285 size_t propertyDataSize () const;312 size_t propertyDataSize () const;
@@ -305,6 +332,11 @@
305{332{
306 public:333 public:
307334
335 FakeDecorationList () :
336 mDecorationType (WINDOW_DECORATION_TYPE_PIXMAP)
337 {
338 }
339
308 FakeDecorationList (unsigned int type) :340 FakeDecorationList (unsigned int type) :
309 mDecorationType (type)341 mDecorationType (type)
310 {342 {
@@ -314,6 +346,7 @@
314 void RemoveDecoration (unsigned int type,346 void RemoveDecoration (unsigned int type,
315 unsigned int state,347 unsigned int state,
316 unsigned int actions);348 unsigned int actions);
349 void RemoveAllDecorations ();
317350
318 void SetPropertyOnWindow (Display *dpy,351 void SetPropertyOnWindow (Display *dpy,
319 Window w,352 Window w,
@@ -558,6 +591,22 @@
558 return WINDOW_PROP_SIZE;591 return WINDOW_PROP_SIZE;
559}592}
560593
594CompPoint
595cdt::FakeWindowTypeDecoration::restoredFrameWindowOffset () const
596{
597 int xOffset = -mRestored.left;
598 int yOffset = -mRestored.top;
599
600 return CompPoint (xOffset, yOffset);
601}
602
603CompSize
604cdt::FakeWindowTypeDecoration::restoredDecorationSize () const
605{
606 return CompSize (mRestored.left + mRestored.right,
607 mRestored.top + mRestored.bottom);
608}
609
561cdt::FakePixmapTypeDecoration::FakePixmapTypeDecoration (unsigned int type,610cdt::FakePixmapTypeDecoration::FakePixmapTypeDecoration (unsigned int type,
562 unsigned int state,611 unsigned int state,
563 unsigned int actions,612 unsigned int actions,
@@ -636,6 +685,34 @@
636 vec.push_back (propData[i]);685 vec.push_back (propData[i]);
637}686}
638687
688CompPoint
689cdt::FakePixmapTypeDecoration::restoredFrameWindowOffset () const
690{
691 int xOffset = mRestoredBorder.left - mRestoredInput.left;
692 int yOffset = mRestoredBorder.top - mRestoredInput.top;
693
694 return CompPoint (xOffset, yOffset);
695}
696
697CompSize
698cdt::FakePixmapTypeDecoration::restoredDecorationSize () const
699{
700 return CompSize (mRestoredInput.left + mRestoredInput.right,
701 mRestoredInput.top + mRestoredInput.bottom);
702}
703
704void
705cdt::FakePixmapTypeDecoration::changeRestoredBorder (const decor_extents_t &b)
706{
707 mRestoredBorder = b;
708}
709
710void
711cdt::FakePixmapTypeDecoration::changeRestoredInput (const decor_extents_t &i)
712{
713 mRestoredInput = i;
714}
715
639void716void
640cdt::FakeDecorationList::AddDecoration (const cdt::FakeDecoration::Ptr &decoration)717cdt::FakeDecorationList::AddDecoration (const cdt::FakeDecoration::Ptr &decoration)
641{718{
@@ -668,6 +745,11 @@
668 decorations.end ());745 decorations.end ());
669}746}
670747
748void cdt::FakeDecorationList::RemoveAllDecorations ()
749{
750 decorations.clear ();
751}
752
671void753void
672cdt::FakeDecorationList::SetPropertyOnWindow (Display *dpy,754cdt::FakeDecorationList::SetPropertyOnWindow (Display *dpy,
673 Window w,755 Window w,
@@ -894,12 +976,16 @@
894976
895 void SetUpDecorator ();977 void SetUpDecorator ();
896978
979 void DisallowDecorationsOnWindow (Window window);
980 void AllowDecorationsOnWindow (Window window);
981
897 std::auto_ptr <cdt::FakeDecorator> decorator;982 std::auto_ptr <cdt::FakeDecorator> decorator;
898983
899 Atom NETWMFrameExtentsAtom;984 Atom NETWMFrameExtentsAtom;
900 Atom WindowDecorationAtom;985 Atom WindowDecorationAtom;
901 Atom DefaultActiveDecorationAtom;986 Atom DefaultActiveDecorationAtom;
902 Atom DefaultBareDecorationAtom;987 Atom DefaultBareDecorationAtom;
988 Atom MWMHintsAtom;
903};989};
904990
905void991void
@@ -934,6 +1020,41 @@
934 SupportedDecorations ()));1020 SupportedDecorations ()));
935}1021}
9361022
1023namespace
1024{
1025void ChangeDecorationState (Display *display,
1026 Window window,
1027 unsigned int decorationFlags)
1028{
1029 Atom mwmHintsAtom = XInternAtom (display, "_MOTIF_WM_HINTS", 0);
1030 cdt::MWMHints hints;
1031
1032 hints.flags = 1L << 1;
1033 hints.decorations = decorationFlags;
1034
1035 XChangeProperty (display,
1036 window,
1037 mwmHintsAtom,
1038 mwmHintsAtom,
1039 32,
1040 PropModeReplace,
1041 reinterpret_cast <unsigned char *> (&hints),
1042 3);
1043}
1044}
1045
1046void
1047DecorFakeDecoratorAcceptance::DisallowDecorationsOnWindow (Window window)
1048{
1049 ChangeDecorationState (Display (), window, 0);
1050}
1051
1052void
1053DecorFakeDecoratorAcceptance::AllowDecorationsOnWindow (Window window)
1054{
1055 ChangeDecorationState (Display (), window, cdt::MwmDecor);
1056}
1057
937void1058void
938DecorFakeDecoratorAcceptance::TearDown ()1059DecorFakeDecoratorAcceptance::TearDown ()
939{1060{
@@ -983,6 +1104,37 @@
983 matcher)));1104 matcher)));
984}1105}
9851106
1107void WaitForConfigureOn (Display *display,
1108 Window window,
1109 int x,
1110 int y,
1111 unsigned int width,
1112 unsigned int height,
1113 unsigned int mask)
1114{
1115 /* Wait for the ConfigureNotify on the frame window
1116 * after an offset move */
1117 ct::ConfigureNotifyXEventMatcher matcher (None,
1118 0,
1119 x,
1120 y,
1121 width,
1122 height,
1123 mask);
1124
1125 /* The use of the timeout is currently because some functionality
1126 * is broken which would cause these barrier conditions to never
1127 * eventuate. For now just get to the fail condition */
1128 Advance (display,
1129 ct::WaitForEventOfTypeOnWindowMatching (display,
1130 window,
1131 ConfigureNotify,
1132 -1,
1133 -1,
1134 matcher,
1135 1000));
1136}
1137
986void WaitForFrameExtents (Display *dpy,1138void WaitForFrameExtents (Display *dpy,
987 Window w)1139 Window w)
988{1140{
@@ -1158,7 +1310,7 @@
11581310
1159namespace1311namespace
1160{1312{
1161cdt::FakeDecoration::Ptr1313cdt::FakePixmapTypeDecoration::Ptr
1162MakeFakePixmapTypeDecoration (unsigned int type,1314MakeFakePixmapTypeDecoration (unsigned int type,
1163 unsigned int state,1315 unsigned int state,
1164 unsigned int actions,1316 unsigned int actions,
@@ -1170,7 +1322,7 @@
1170 const decor_extents_t &maximizedInput,1322 const decor_extents_t &maximizedInput,
1171 Display *dpy)1323 Display *dpy)
1172{1324{
1173 cdt::FakeDecoration *decoration =1325 cdt::FakePixmapTypeDecoration *decoration =
1174 new cdt::FakePixmapTypeDecoration (type,1326 new cdt::FakePixmapTypeDecoration (type,
1175 state,1327 state,
1176 actions,1328 actions,
@@ -1182,7 +1334,7 @@
1182 maximizedInput,1334 maximizedInput,
1183 dpy);1335 dpy);
11841336
1185 return boost::shared_ptr <cdt::FakeDecoration> (decoration);1337 return boost::shared_ptr <cdt::FakePixmapTypeDecoration> (decoration);
1186}1338}
11871339
1188decor_extents_t1340decor_extents_t
@@ -1469,52 +1621,209 @@
14691621
1470/* TODO: Get bare decorations tests */1622/* TODO: Get bare decorations tests */
14711623
1472class PixmapDecoratedWindowAcceptance :1624/* Helper class with some useful member functions */
1625class PixmapDecoratorAcceptance :
1473 public DecorWithPixmapDefaultsAcceptance1626 public DecorWithPixmapDefaultsAcceptance
1474{1627{
1475 public:1628 public:
1476 1629
1477 PixmapDecoratedWindowAcceptance ();1630 typedef cdt::FakeDecoration::Ptr FakeDecorPtr;
1478 1631 typedef cdt::FakePixmapTypeDecoration::Ptr FakePixDecorPtr;
1479 virtual void SetUp ();1632
1480 virtual void TearDown ();1633 Window CreateDecoratableWindow (::Display *display);
14811634 Window MapAndReparent (::Display *display,
1482 virtual bool StartDecoratorOnSetUp () const;1635 Window window);
1483 1636
1637 void DecorateWindow (::Display *display,
1638 Window window,
1639 const FakePixDecorPtr &decoration);
1640 void WaitForDecoration (::Display *display,
1641 Window window,
1642 const FakeDecorPtr &decoration);
1643 void WaitForDecorationUpdate (::Display *display,
1644 Window window,
1645 const FakeDecorPtr &decor);
1646
1647 cdt::FakeDecorationList GetDecorations (Window window);
1648 Window GetParent (Window window);
1649
1650 void ReconfigureDecoration (::Display *display,
1651 Window window,
1652 const FakePixDecorPtr &decor,
1653 cdt::FakeDecorationList &list,
1654 const decor_extents_t &border,
1655 const decor_extents_t &input);
1656
1657 bool DestroyWindow (::Display *display,
1658 Window window);
1659
1660
1484 protected:1661 protected:
1485 1662
1486 Window mWindow;1663 std::map <Window, cdt::FakeDecorationList> windowDecorations;
1487 Window mParent;1664 std::map <Window, Window> windowParents;
1488 cdt::FakeDecorationList mDecorations;
1489};1665};
14901666
1491PixmapDecoratedWindowAcceptance::PixmapDecoratedWindowAcceptance () :1667Window
1492 mDecorations (WINDOW_DECORATION_TYPE_PIXMAP)1668PixmapDecoratorAcceptance::CreateDecoratableWindow (::Display *display)
1493{1669{
1670 return ct::CreateNormalWindow (display);
1494}1671}
14951672
1496void1673Window
1497PixmapDecoratedWindowAcceptance::SetUp ()1674PixmapDecoratorAcceptance::MapAndReparent (::Display *display,
1675 Window window)
1498{1676{
1499 DecorWithPixmapDefaultsAcceptance::SetUp ();1677 if (windowParents.find (window) != windowParents.end ())
1678 return windowParents[window];
15001679
1501 mWindow = ct::CreateNormalWindow (Display ());1680 XSelectInput (display, window,
1502 XSelectInput (Display (), mWindow,
1503 StructureNotifyMask |1681 StructureNotifyMask |
1504 PropertyChangeMask);1682 PropertyChangeMask);
1505 XMapRaised (Display (), mWindow);1683 XMapRaised (display, window);
15061684
1507 /* Wait for the window to be reparented */1685 /* Wait for the window to be reparented */
1508 Advance (Display (),1686 Advance (Display (),
1509 ct::WaitForEventOfTypeOnWindow (Display (),1687 ct::WaitForEventOfTypeOnWindow (display,
1510 mWindow,1688 window,
1511 ReparentNotify,1689 ReparentNotify,
1512 -1,1690 -1,
1513 -1));1691 -1));
15141692
1515 /* Select for StructureNotify events on the parent window */1693 /* Select for StructureNotify on the parent and wrapper
1516 mParent = FindParent (Display (), mWindow);1694 * windows */
1517 XSelectInput (Display (), mParent, StructureNotifyMask);1695 windowParents[window] = FindParent (display, window);
1696
1697 Window root = 0;
1698 Window wrapper = ct::GetImmediateParent (display, window, root);
1699
1700 XSelectInput (display, windowParents[window], StructureNotifyMask);
1701 XSelectInput (display, wrapper, StructureNotifyMask);
1702
1703 return windowParents[window];
1704}
1705
1706void
1707PixmapDecoratorAcceptance::DecorateWindow (::Display *display,
1708 Window window,
1709 const FakePixDecorPtr &decoration)
1710{
1711 windowDecorations[window] = cdt::FakeDecorationList (WINDOW_DECORATION_TYPE_PIXMAP);
1712 windowDecorations[window].AddDecoration (decoration);
1713 windowDecorations[window].SetPropertyOnWindow (display,
1714 window,
1715 WindowDecorationAtom);
1716}
1717
1718void
1719PixmapDecoratorAcceptance::WaitForDecoration (::Display *display,
1720 Window window,
1721 const FakeDecorPtr &decoration)
1722{
1723 WaitForPropertyNotify (display, window, DECOR_INPUT_FRAME_ATOM_NAME);
1724 WaitForDecorationUpdate (display, window, decoration);
1725}
1726
1727void
1728PixmapDecoratorAcceptance::WaitForDecorationUpdate (::Display *display,
1729 Window window,
1730 const FakeDecorPtr &decor)
1731{
1732 /* Wait for the frame extents to change */
1733 WaitForPropertyNotify (display, window, "_NET_FRAME_EXTENTS");
1734
1735 const CompPoint &framePos (decor->restoredFrameWindowOffset ());
1736
1737 /* Wait for the ConfigureNotify on the frame window
1738 * after an offset move */
1739 WaitForConfigureOn (display,
1740 GetParent (window),
1741 framePos.x (),
1742 framePos.y (),
1743 0,
1744 0,
1745 CWX | CWY);
1746}
1747
1748void
1749PixmapDecoratorAcceptance::ReconfigureDecoration (::Display *display,
1750 Window window,
1751 const FakePixDecorPtr &decor,
1752 cdt::FakeDecorationList &list,
1753 const decor_extents_t &border,
1754 const decor_extents_t &input)
1755{
1756 decor->changeRestoredInput (input);
1757 decor->changeRestoredBorder (border);
1758 list.SetPropertyOnWindow (display,
1759 window,
1760 WindowDecorationAtom);
1761
1762 WaitForDecorationUpdate (display, window, decor);
1763}
1764
1765bool
1766PixmapDecoratorAcceptance::DestroyWindow (::Display *display,
1767 Window window)
1768{
1769 std::map <Window, Window>::iterator parentIterator =
1770 windowParents.find (window);
1771 std::map <Window, cdt::FakeDecorationList>::iterator decorIterator =
1772 windowDecorations.find (window);
1773
1774 if (parentIterator != windowParents.end ())
1775 windowParents.erase (parentIterator);
1776 if (decorIterator != windowDecorations.end ())
1777 {
1778 windowDecorations[window].RemoveAllDecorations ();
1779 windowDecorations.erase (decorIterator);
1780 }
1781
1782 XDestroyWindow (display, window);
1783
1784 return parentIterator != windowParents.end () ||
1785 decorIterator != windowDecorations.end ();
1786}
1787
1788Window
1789PixmapDecoratorAcceptance::GetParent (Window window)
1790{
1791 return windowParents[window];
1792}
1793
1794cdt::FakeDecorationList
1795PixmapDecoratorAcceptance::GetDecorations (Window window)
1796{
1797 return windowDecorations[window];
1798}
1799
1800class PixmapDecoratedWindowAcceptance :
1801 public PixmapDecoratorAcceptance
1802{
1803 public:
1804
1805 virtual void SetUp ();
1806 virtual void TearDown ();
1807
1808 virtual bool StartDecoratorOnSetUp () const;
1809
1810 protected:
1811
1812 Window mTestWindow;
1813 Window mTestWindowParent;
1814
1815 cdt::FakePixmapTypeDecoration::Ptr mTestWindowDecoration;
1816};
1817
1818void
1819PixmapDecoratedWindowAcceptance::SetUp ()
1820{
1821 DecorWithPixmapDefaultsAcceptance::SetUp ();
1822
1823 ::Display *display = Display ();
1824
1825 mTestWindow = CreateDecoratableWindow (display);
1826 mTestWindowParent = MapAndReparent (display, mTestWindow);
15181827
1519 /* Start the decorator */1828 /* Start the decorator */
1520 SetUpDecorator ();1829 SetUpDecorator ();
@@ -1523,7 +1832,7 @@
1523 unsigned int ResIn = ActiveInputExtent;1832 unsigned int ResIn = ActiveInputExtent;
1524 unsigned int MaxEx = MaximizedBorderExtent;1833 unsigned int MaxEx = MaximizedBorderExtent;
15251834
1526 cdt::FakeDecoration::Ptr decoration =1835 mTestWindowDecoration =
1527 MakeFakePixmapTypeDecoration (DECOR_WINDOW_TYPE_NORMAL,1836 MakeFakePixmapTypeDecoration (DECOR_WINDOW_TYPE_NORMAL,
1528 0,1837 0,
1529 0,1838 0,
@@ -1535,38 +1844,14 @@
1535 DecorationExtents (MaxEx, MaxEx, MaxEx, MaxEx),1844 DecorationExtents (MaxEx, MaxEx, MaxEx, MaxEx),
1536 Display ());1845 Display ());
15371846
1538 mDecorations.AddDecoration (decoration);1847 DecorateWindow (display, mTestWindow, mTestWindowDecoration);
1539 mDecorations.SetPropertyOnWindow (Display (),1848 WaitForDecoration (display, mTestWindow, mTestWindowDecoration);
1540 mWindow,
1541 WindowDecorationAtom);
1542
1543 WaitForPropertyNotify (Display (), mWindow, DECOR_INPUT_FRAME_ATOM_NAME);
1544 WaitForPropertyNotify (Display (), mWindow, "_NET_FRAME_EXTENTS");
1545
1546 /* Wait for the parent window to be moved to -2, -2 */
1547 ct::ConfigureNotifyXEventMatcher matcher (None,
1548 0,
1549 ResBo - ResIn,
1550 ResBo - ResIn,
1551 0,
1552 0,
1553 CWX | CWY);
1554
1555 Advance (Display (),
1556 ct::WaitForEventOfTypeOnWindowMatching (Display (),
1557 mParent,
1558 ConfigureNotify,
1559 -1,
1560 -1,
1561 matcher));
1562}1849}
15631850
1564void1851void
1565PixmapDecoratedWindowAcceptance::TearDown ()1852PixmapDecoratedWindowAcceptance::TearDown ()
1566{1853{
1567 mDecorations.RemoveDecoration (DECOR_WINDOW_TYPE_NORMAL, 0, 0);1854 DestroyWindow (Display (), mTestWindow);
1568
1569 XDestroyWindow (Display (), mWindow);
15701855
1571 DecorWithPixmapDefaultsAcceptance::TearDown ();1856 DecorWithPixmapDefaultsAcceptance::TearDown ();
1572}1857}
@@ -1636,18 +1921,18 @@
1636 ChangeStateOfWindow (Display (),1921 ChangeStateOfWindow (Display (),
1637 AddState,1922 AddState,
1638 "_NET_WM_STATE_MAXIMIZED_VERT",1923 "_NET_WM_STATE_MAXIMIZED_VERT",
1639 mWindow);1924 mTestWindow);
16401925
1641 ChangeStateOfWindow (Display (),1926 ChangeStateOfWindow (Display (),
1642 AddState,1927 AddState,
1643 "_NET_WM_STATE_MAXIMIZED_HORZ",1928 "_NET_WM_STATE_MAXIMIZED_HORZ",
1644 mWindow);1929 mTestWindow);
16451930
1646 WaitForPropertyNotify (Display (), mWindow, "_NET_FRAME_EXTENTS");1931 WaitForPropertyNotify (Display (), mTestWindow, "_NET_FRAME_EXTENTS");
16471932
1648 boost::shared_ptr <unsigned char> data =1933 boost::shared_ptr <unsigned char> data =
1649 FetchCardinalProperty (Display (),1934 FetchCardinalProperty (Display (),
1650 mWindow,1935 mTestWindow,
1651 NETWMFrameExtentsAtom);1936 NETWMFrameExtentsAtom);
16521937
1653 unsigned long *frameExtents =1938 unsigned long *frameExtents =
@@ -1663,13 +1948,13 @@
1663 ChangeStateOfWindow (Display (),1948 ChangeStateOfWindow (Display (),
1664 AddState,1949 AddState,
1665 "_NET_WM_STATE_MAXIMIZED_VERT",1950 "_NET_WM_STATE_MAXIMIZED_VERT",
1666 mWindow);1951 mTestWindow);
16671952
1668 WaitForPropertyNotify (Display (), mWindow, "_NET_FRAME_EXTENTS");1953 WaitForPropertyNotify (Display (), mTestWindow, "_NET_FRAME_EXTENTS");
16691954
1670 boost::shared_ptr <unsigned char> data =1955 boost::shared_ptr <unsigned char> data =
1671 FetchCardinalProperty (Display (),1956 FetchCardinalProperty (Display (),
1672 mWindow,1957 mTestWindow,
1673 NETWMFrameExtentsAtom);1958 NETWMFrameExtentsAtom);
16741959
1675 unsigned long *frameExtents =1960 unsigned long *frameExtents =
@@ -1685,13 +1970,13 @@
1685 ChangeStateOfWindow (Display (),1970 ChangeStateOfWindow (Display (),
1686 AddState,1971 AddState,
1687 "_NET_WM_STATE_MAXIMIZED_HORZ",1972 "_NET_WM_STATE_MAXIMIZED_HORZ",
1688 mWindow);1973 mTestWindow);
16891974
1690 WaitForPropertyNotify (Display (), mWindow, "_NET_FRAME_EXTENTS");1975 WaitForPropertyNotify (Display (), mTestWindow, "_NET_FRAME_EXTENTS");
16911976
1692 boost::shared_ptr <unsigned char> data =1977 boost::shared_ptr <unsigned char> data =
1693 FetchCardinalProperty (Display (),1978 FetchCardinalProperty (Display (),
1694 mWindow,1979 mTestWindow,
1695 NETWMFrameExtentsAtom);1980 NETWMFrameExtentsAtom);
16961981
1697 unsigned long *frameExtents =1982 unsigned long *frameExtents =
@@ -1712,12 +1997,12 @@
1712 ChangeStateOfWindow (Display (),1997 ChangeStateOfWindow (Display (),
1713 AddState,1998 AddState,
1714 "_NET_WM_STATE_MAXIMIZED_VERT",1999 "_NET_WM_STATE_MAXIMIZED_VERT",
1715 mWindow);2000 mTestWindow);
17162001
1717 ChangeStateOfWindow (Display (),2002 ChangeStateOfWindow (Display (),
1718 AddState,2003 AddState,
1719 "_NET_WM_STATE_MAXIMIZED_HORZ",2004 "_NET_WM_STATE_MAXIMIZED_HORZ",
1720 mWindow);2005 mTestWindow);
17212006
1722 ct::ConfigureNotifyXEventMatcher matcher (None,2007 ct::ConfigureNotifyXEventMatcher matcher (None,
1723 0,2008 0,
@@ -1729,7 +2014,7 @@
17292014
1730 EXPECT_TRUE (Advance (Display (),2015 EXPECT_TRUE (Advance (Display (),
1731 ct::WaitForEventOfTypeOnWindowMatching (Display (),2016 ct::WaitForEventOfTypeOnWindowMatching (Display (),
1732 mParent,2017 mTestWindowParent,
1733 ConfigureNotify,2018 ConfigureNotify,
1734 -1,2019 -1,
1735 -1,2020 -1,
@@ -1744,7 +2029,7 @@
1744 ChangeStateOfWindow (Display (),2029 ChangeStateOfWindow (Display (),
1745 AddState,2030 AddState,
1746 "_NET_WM_STATE_MAXIMIZED_VERT",2031 "_NET_WM_STATE_MAXIMIZED_VERT",
1747 mWindow);2032 mTestWindow);
17482033
1749 ct::ConfigureNotifyXEventMatcher matcher (None,2034 ct::ConfigureNotifyXEventMatcher matcher (None,
1750 0,2035 0,
@@ -1756,7 +2041,7 @@
17562041
1757 EXPECT_TRUE (Advance (Display (),2042 EXPECT_TRUE (Advance (Display (),
1758 ct::WaitForEventOfTypeOnWindowMatching (Display (),2043 ct::WaitForEventOfTypeOnWindowMatching (Display (),
1759 mParent,2044 mTestWindowParent,
1760 ConfigureNotify,2045 ConfigureNotify,
1761 -1,2046 -1,
1762 -1,2047 -1,
@@ -1771,7 +2056,7 @@
1771 ChangeStateOfWindow (Display (),2056 ChangeStateOfWindow (Display (),
1772 AddState,2057 AddState,
1773 "_NET_WM_STATE_MAXIMIZED_HORZ",2058 "_NET_WM_STATE_MAXIMIZED_HORZ",
1774 mWindow);2059 mTestWindow);
17752060
1776 ct::ConfigureNotifyXEventMatcher matcher (None,2061 ct::ConfigureNotifyXEventMatcher matcher (None,
1777 0,2062 0,
@@ -1783,7 +2068,7 @@
17832068
1784 EXPECT_TRUE (Advance (Display (),2069 EXPECT_TRUE (Advance (Display (),
1785 ct::WaitForEventOfTypeOnWindowMatching (Display (),2070 ct::WaitForEventOfTypeOnWindowMatching (Display (),
1786 mParent,2071 mTestWindowParent,
1787 ConfigureNotify,2072 ConfigureNotify,
1788 -1,2073 -1,
1789 -1,2074 -1,
@@ -1792,12 +2077,58 @@
17922077
1793namespace2078namespace
1794{2079{
2080void RelativeWindowGeometry (Display *dpy,
2081 Window w,
2082 int &x,
2083 int &y,
2084 unsigned int &width,
2085 unsigned int &height,
2086 unsigned int &border)
2087{
2088 Window root;
2089 unsigned int depth;
2090
2091 if (!XGetGeometry (dpy, w, &root, &x, &y, &width, &height, &border, &depth))
2092 throw std::logic_error ("XGetGeometry failed");
2093}
2094
2095void AbsoluteWindowGeometry (::Display *display,
2096 Window window,
2097 int &x,
2098 int &y,
2099 unsigned int &width,
2100 unsigned int &height,
2101 unsigned int &border)
2102{
2103 Window root;
2104 Window child;
2105 unsigned int depth;
2106
2107 if (!XGetGeometry (display, window, &root,
2108 &x, &y, &width, &height,
2109 &border, &depth))
2110 throw std::logic_error ("XGetGeometry failed");
2111
2112 if (!XTranslateCoordinates (display, window, root, x, y,
2113 &x, &y, &child))
2114 throw std::logic_error ("XTranslateCoordinates failed");
2115}
2116
2117typedef void (*RetrievalFunc) (Display *dpy,
2118 Window window,
2119 int &x,
2120 int &y,
2121 unsigned int &width,
2122 unsigned int &height,
2123 unsigned int &border);
2124
1795class WindowGeometryMatcher :2125class WindowGeometryMatcher :
1796 public MatcherInterface <Window>2126 public MatcherInterface <Window>
1797{2127{
1798 public:2128 public:
17992129
1800 WindowGeometryMatcher (Display *dpy,2130 WindowGeometryMatcher (Display *dpy,
2131 RetrievalFunc func,
1801 const Matcher <int> &x,2132 const Matcher <int> &x,
1802 const Matcher <int> &y,2133 const Matcher <int> &y,
1803 const Matcher <unsigned int> &width,2134 const Matcher <unsigned int> &width,
@@ -1811,6 +2142,8 @@
18112142
1812 Display *mDpy;2143 Display *mDpy;
18132144
2145 RetrievalFunc mFunc;
2146
1814 Matcher <int> mX;2147 Matcher <int> mX;
1815 Matcher <int> mY;2148 Matcher <int> mY;
1816 Matcher <unsigned int> mWidth;2149 Matcher <unsigned int> mWidth;
@@ -1819,14 +2152,16 @@
1819};2152};
18202153
1821Matcher <Window>2154Matcher <Window>
1822WindowGeometry (Display *dpy,2155HasGeometry (Display *dpy,
1823 const Matcher <int> &x,2156 RetrievalFunc func,
1824 const Matcher <int> &y,2157 const Matcher <int> &x,
1825 const Matcher <unsigned int> &width,2158 const Matcher <int> &y,
1826 const Matcher <unsigned int> &height,2159 const Matcher <unsigned int> &width,
1827 const Matcher <unsigned int> &border)2160 const Matcher <unsigned int> &height,
2161 const Matcher <unsigned int> &border)
1828{2162{
1829 return MakeMatcher (new WindowGeometryMatcher (dpy,2163 return MakeMatcher (new WindowGeometryMatcher (dpy,
2164 func,
1830 x,2165 x,
1831 y,2166 y,
1832 width,2167 width,
@@ -1836,12 +2171,14 @@
1836}2171}
18372172
1838WindowGeometryMatcher::WindowGeometryMatcher (Display *dpy,2173WindowGeometryMatcher::WindowGeometryMatcher (Display *dpy,
2174 RetrievalFunc func,
1839 const Matcher <int> &x,2175 const Matcher <int> &x,
1840 const Matcher <int> &y,2176 const Matcher <int> &y,
1841 const Matcher <unsigned int> &width,2177 const Matcher <unsigned int> &width,
1842 const Matcher <unsigned int> &height,2178 const Matcher <unsigned int> &height,
1843 const Matcher <unsigned int> &border) :2179 const Matcher <unsigned int> &border) :
1844 mDpy (dpy),2180 mDpy (dpy),
2181 mFunc (func),
1845 mX (x),2182 mX (x),
1846 mY (y),2183 mY (y),
1847 mWidth (width),2184 mWidth (width),
@@ -1854,12 +2191,10 @@
1854WindowGeometryMatcher::MatchAndExplain (Window w,2191WindowGeometryMatcher::MatchAndExplain (Window w,
1855 MatchResultListener *listener) const2192 MatchResultListener *listener) const
1856{2193{
1857 Window root;
1858 int x, y;2194 int x, y;
1859 unsigned int width, height, border, depth;2195 unsigned int width, height, border;
18602196
1861 if (!XGetGeometry (mDpy, w, &root, &x, &y, &width, &height, &border, &depth))2197 mFunc (mDpy, w, x, y, width, height, border);
1862 throw std::logic_error ("XGetGeometry failed");
18632198
1864 bool match = mX.MatchAndExplain (x, listener) &&2199 bool match = mX.MatchAndExplain (x, listener) &&
1865 mY.MatchAndExplain (y, listener) &&2200 mY.MatchAndExplain (y, listener) &&
@@ -1925,39 +2260,37 @@
1925 XWindowAttributes rootAttrib, attrib;2260 XWindowAttributes rootAttrib, attrib;
1926 XGetWindowAttributes (Display (), DefaultRootWindow (Display ()), &rootAttrib);2261 XGetWindowAttributes (Display (), DefaultRootWindow (Display ()), &rootAttrib);
19272262
1928 WindowBorderPositionAttributes (Display (), mParent, attrib, ActiveBorderExtent, ActiveInputExtent);2263 WindowBorderPositionAttributes (Display (),
2264 mTestWindowParent,
2265 attrib,
2266 ActiveBorderExtent,
2267 ActiveInputExtent);
19292268
1930 ChangeStateOfWindow (Display (),2269 ChangeStateOfWindow (Display (),
1931 AddState,2270 AddState,
1932 "_NET_WM_STATE_MAXIMIZED_VERT",2271 "_NET_WM_STATE_MAXIMIZED_VERT",
1933 mWindow);2272 mTestWindow);
19342273
1935 /* Wait for the window to be maximized first */2274 /* Wait for the window to be maximized first */
1936 ct::ConfigureNotifyXEventMatcher matcher (None,2275 WaitForConfigureOn (Display (),
1937 0,2276 mTestWindowParent,
1938 0,2277 0,
1939 0,2278 0,
1940 0,2279 0,
1941 rootAttrib.height,2280 rootAttrib.height,
1942 CWY | CWHeight);2281 CWY | CWHeight);
1943
1944 Advance (Display (),
1945 ct::WaitForEventOfTypeOnWindowMatching (Display (),
1946 mParent,
1947 ConfigureNotify,
1948 -1,
1949 -1,
1950 matcher));
19512282
1952 /* Query the window geometry and ensure that the width and2283 /* Query the window geometry and ensure that the width and
1953 * height have remained the same (adding on any extended borders,2284 * height have remained the same (adding on any extended borders,
1954 * in this case 0) */2285 * in this case 0) */
1955 EXPECT_THAT (mParent, WindowGeometry (Display (),2286 EXPECT_THAT (mTestWindowParent,
1956 attrib.x,2287 HasGeometry (Display (),
1957 _,2288 RelativeWindowGeometry,
1958 attrib.width,2289 attrib.x,
1959 _,2290 _,
1960 _));2291 attrib.width,
2292 _,
2293 _));
1961}2294}
19622295
1963/* DISABLED - Upon maximization, y offset is 1, height offset is 10 */2296/* DISABLED - Upon maximization, y offset is 1, height offset is 10 */
@@ -1966,38 +2299,350 @@
1966 XWindowAttributes rootAttrib, attrib;2299 XWindowAttributes rootAttrib, attrib;
1967 XGetWindowAttributes (Display (), DefaultRootWindow (Display ()), &rootAttrib);2300 XGetWindowAttributes (Display (), DefaultRootWindow (Display ()), &rootAttrib);
19682301
1969 WindowBorderPositionAttributes (Display (), mParent, attrib, ActiveBorderExtent, ActiveInputExtent);2302 WindowBorderPositionAttributes (Display (),
2303 mTestWindowParent,
2304 attrib,
2305 ActiveBorderExtent,
2306 ActiveInputExtent);
19702307
1971 ChangeStateOfWindow (Display (),2308 ChangeStateOfWindow (Display (),
1972 AddState,2309 AddState,
1973 "_NET_WM_STATE_MAXIMIZED_HORZ",2310 "_NET_WM_STATE_MAXIMIZED_HORZ",
1974 mWindow);2311 mTestWindow);
19752312
1976 /* Wait for the window to be maximized first */2313 /* Wait for the window to be maximized first */
1977 ct::ConfigureNotifyXEventMatcher matcher (None,2314 WaitForConfigureOn (Display (),
1978 0,2315 mTestWindowParent,
1979 0,2316 0,
1980 0,2317 0,
1981 rootAttrib.width,2318 rootAttrib.width,
1982 0,2319 0,
1983 CWX | CWWidth);2320 CWX | CWWidth);
1984
1985 Advance (Display (),
1986 ct::WaitForEventOfTypeOnWindowMatching (Display (),
1987 mParent,
1988 ConfigureNotify,
1989 -1,
1990 -1,
1991 matcher));
19922321
1993 /* Query the window geometry and ensure that the width and2322 /* Query the window geometry and ensure that the width and
1994 * height have remained the same (adding on any extended borders,2323 * height have remained the same (adding on any extended borders,
1995 * in this case 0) */2324 * in this case 0) */
1996 EXPECT_THAT (mParent, WindowGeometry (Display (),2325 EXPECT_THAT (mTestWindowParent,
1997 _,2326 HasGeometry (Display (),
1998 attrib.y,2327 RelativeWindowGeometry,
1999 _,2328 _,
2000 attrib.height,2329 attrib.y,
2001 _));2330 _,
2002}2331 attrib.height,
20032332 _));
2333}
2334
2335/* Ensure that a window expands to its original size when it is
2336 * undecorated */
2337TEST_F (PixmapDecoratedWindowAcceptance, UndecoratedWindowExpandToOrigSize)
2338{
2339 DisallowDecorationsOnWindow (mTestWindow);
2340
2341 WaitForConfigureOn (Display (),
2342 mTestWindowParent,
2343 ct::WINDOW_X,
2344 ct::WINDOW_Y,
2345 ct::WINDOW_WIDTH,
2346 ct::WINDOW_HEIGHT,
2347 CWX | CWY | CWWidth | CWHeight);
2348
2349 EXPECT_THAT (mTestWindow,
2350 HasGeometry (Display (),
2351 AbsoluteWindowGeometry,
2352 ct::WINDOW_X,
2353 ct::WINDOW_Y,
2354 ct::WINDOW_WIDTH,
2355 ct::WINDOW_HEIGHT,
2356 _));
2357}
2358
2359/* DISABLED - Ensure that a window with StaticGravity expands to its
2360 * original size when it is undecorated
2361 *
2362 * X and Y positions do not revert back to their original state.
2363 */
2364TEST_F (PixmapDecoratedWindowAcceptance, DISABLED_UndecorateStaticGravityWindow)
2365{
2366 XSizeHints hints;
2367
2368 hints.flags = PWinGravity;
2369 hints.win_gravity = StaticGravity;
2370
2371 XSetWMNormalHints (Display (), mTestWindow, &hints);
2372 DisallowDecorationsOnWindow (mTestWindow);
2373
2374 WaitForConfigureOn (Display (),
2375 mTestWindowParent,
2376 ct::WINDOW_X,
2377 ct::WINDOW_Y,
2378 ct::WINDOW_WIDTH,
2379 ct::WINDOW_HEIGHT,
2380 CWX | CWY | CWWidth | CWHeight);
2381
2382 EXPECT_THAT (mTestWindow,
2383 HasGeometry (Display (),
2384 AbsoluteWindowGeometry,
2385 ct::WINDOW_X,
2386 ct::WINDOW_Y,
2387 ct::WINDOW_WIDTH,
2388 ct::WINDOW_HEIGHT,
2389 _));
2390}
2391
2392class PixmapDecorationAdjustment :
2393 public PixmapDecoratedWindowAcceptance,
2394 public WithParamInterface <decor_extents_t>
2395{
2396 public:
2397
2398 void MaximizeWindow (Window window);
2399 void RestoreWindow (Window window,
2400 int restoredFrameX,
2401 int restoredFrameY,
2402 unsigned int restoredFrameWidth,
2403 unsigned int restoredFrameHeight);
2404};
2405
2406void
2407PixmapDecorationAdjustment::MaximizeWindow (Window window)
2408{
2409 XWindowAttributes rootAttrib;
2410 XGetWindowAttributes (Display (), DefaultRootWindow (Display ()), &rootAttrib);
2411
2412 ChangeStateOfWindow (Display (),
2413 AddState,
2414 "_NET_WM_STATE_MAXIMIZED_HORZ",
2415 window);
2416
2417 ChangeStateOfWindow (Display (),
2418 AddState,
2419 "_NET_WM_STATE_MAXIMIZED_VERT",
2420 window);
2421
2422 /* Wait for the window to be maximized first */
2423 WaitForConfigureOn (Display (),
2424 mTestWindowParent,
2425 0,
2426 0,
2427 rootAttrib.width,
2428 rootAttrib.height,
2429 CWX | CWY | CWWidth | CWHeight);
2430}
2431
2432void
2433PixmapDecorationAdjustment::RestoreWindow (Window window,
2434 int restoredFrameX,
2435 int restoredFrameY,
2436 unsigned int restoredFrameWidth,
2437 unsigned int restoredFrameHeight)
2438{
2439 ChangeStateOfWindow (Display (),
2440 RemoveState,
2441 "_NET_WM_STATE_MAXIMIZED_HORZ",
2442 window);
2443
2444 ChangeStateOfWindow (Display (),
2445 RemoveState,
2446 "_NET_WM_STATE_MAXIMIZED_VERT",
2447 window);
2448
2449 /* Wait for the window to be restored first */
2450 WaitForConfigureOn (Display (),
2451 mTestWindowParent,
2452 restoredFrameX,
2453 restoredFrameY,
2454 restoredFrameWidth,
2455 restoredFrameHeight,
2456 CWX | CWY | CWWidth | CWHeight);
2457}
2458
2459TEST_P (PixmapDecorationAdjustment, AdjustRestoredWindowBorderMovesClient)
2460{
2461 ReconfigureDecoration (Display (),
2462 mTestWindow,
2463 mTestWindowDecoration,
2464 windowDecorations[mTestWindow],
2465 GetParam (),
2466 GetParam ());
2467
2468 EXPECT_THAT (mTestWindow, HasGeometry (Display (),
2469 AbsoluteWindowGeometry,
2470 ct::WINDOW_X + GetParam ().left,
2471 ct::WINDOW_Y + GetParam ().top,
2472 _,
2473 _,
2474 _));
2475}
2476
2477TEST_P (PixmapDecorationAdjustment, DISABLED_AdjustRestoredWindowBorderShrinkClient)
2478{
2479 ReconfigureDecoration (Display (),
2480 mTestWindow,
2481 mTestWindowDecoration,
2482 windowDecorations[mTestWindow],
2483 GetParam (),
2484 GetParam ());
2485
2486 EXPECT_THAT (mTestWindow, HasGeometry (Display (),
2487 AbsoluteWindowGeometry,
2488 _,
2489 _,
2490 ct::WINDOW_WIDTH - (GetParam ().left +
2491 GetParam ().right),
2492 ct::WINDOW_HEIGHT - (GetParam ().top +
2493 GetParam ().bottom),
2494 _));
2495}
2496
2497TEST_P (PixmapDecorationAdjustment, DISABLED_ClientExpandsAsBorderShrinks)
2498{
2499 decor_extents_t newExtents = GetParam ();
2500
2501 ReconfigureDecoration (Display (),
2502 mTestWindow,
2503 mTestWindowDecoration,
2504 windowDecorations[mTestWindow],
2505 DecorationExtents (10, 10, 10, 10),
2506 DecorationExtents (10, 10, 10, 10));
2507
2508 ReconfigureDecoration (Display (),
2509 mTestWindow,
2510 mTestWindowDecoration,
2511 windowDecorations[mTestWindow],
2512 newExtents,
2513 DecorationExtents (10, 10, 10, 10));
2514
2515 EXPECT_THAT (mTestWindow, HasGeometry (Display (),
2516 AbsoluteWindowGeometry,
2517 _,
2518 _,
2519 ct::WINDOW_WIDTH - (newExtents.left +
2520 newExtents.right),
2521 ct::WINDOW_HEIGHT - (newExtents.top +
2522 newExtents.bottom),
2523 _));
2524}
2525
2526TEST_P (PixmapDecorationAdjustment, DISABLED_ClientExpandsAsBorderShrinksWhilstMaximized)
2527{
2528 decor_extents_t newExtents = GetParam ();
2529
2530 ReconfigureDecoration (Display (),
2531 mTestWindow,
2532 mTestWindowDecoration,
2533 windowDecorations[mTestWindow],
2534 DecorationExtents (10, 10, 10, 10),
2535 DecorationExtents (10, 10, 10, 10));
2536
2537 MaximizeWindow (mTestWindow);
2538
2539 /* Set the property on the window, then demaximize without waiting
2540 * for a response we will continue to use the maximized window decoration */
2541 mTestWindowDecoration->changeRestoredBorder (newExtents);
2542 windowDecorations[mTestWindow].SetPropertyOnWindow (Display (),
2543 mTestWindow,
2544 WindowDecorationAtom);
2545
2546 const CompPoint &off (mTestWindowDecoration->restoredFrameWindowOffset ());
2547 const CompSize &size (mTestWindowDecoration->restoredDecorationSize ());
2548
2549 RestoreWindow (mTestWindow,
2550 ct::WINDOW_X - off.x (),
2551 ct::WINDOW_Y - off.y (),
2552 ct::WINDOW_WIDTH + size.width (),
2553 ct::WINDOW_HEIGHT + size.height ());
2554
2555 EXPECT_THAT (mTestWindow, HasGeometry (Display (),
2556 AbsoluteWindowGeometry,
2557 ct::WINDOW_X + newExtents.left,
2558 ct::WINDOW_Y + newExtents.right,
2559 ct::WINDOW_WIDTH - (newExtents.left +
2560 newExtents.right),
2561 ct::WINDOW_HEIGHT - (newExtents.top +
2562 newExtents.bottom),
2563 _));
2564}
2565
2566TEST_P (PixmapDecorationAdjustment, DISABLED_ClientExpandsAsBorderShrinksWhilstUndecorated)
2567{
2568 decor_extents_t newExtents = GetParam ();
2569
2570 ReconfigureDecoration (Display (),
2571 mTestWindow,
2572 mTestWindowDecoration,
2573 windowDecorations[mTestWindow],
2574 DecorationExtents (10, 10, 10, 10),
2575 DecorationExtents (10, 10, 10, 10));
2576
2577 DisallowDecorationsOnWindow (mTestWindow);
2578
2579 WaitForConfigureOn (Display (),
2580 mTestWindowParent,
2581 ct::WINDOW_X,
2582 ct::WINDOW_Y,
2583 ct::WINDOW_WIDTH,
2584 ct::WINDOW_HEIGHT,
2585 CWX | CWY | CWWidth | CWHeight);
2586
2587 /* Set the property on the window, then decorate without waiting
2588 * for a response we will continue to use the maximized window decoration */
2589 mTestWindowDecoration->changeRestoredBorder (newExtents);
2590 windowDecorations[mTestWindow].SetPropertyOnWindow (Display (),
2591 mTestWindow,
2592 WindowDecorationAtom);
2593
2594 AllowDecorationsOnWindow (mTestWindow);
2595
2596 const CompPoint &off (mTestWindowDecoration->restoredFrameWindowOffset ());
2597 const CompSize &size (mTestWindowDecoration->restoredDecorationSize ());
2598
2599 WaitForConfigureOn (Display (),
2600 mTestWindowParent,
2601 ct::WINDOW_X - off.x (),
2602 ct::WINDOW_Y - off.y (),
2603 ct::WINDOW_WIDTH + size.width (),
2604 ct::WINDOW_HEIGHT + size.height (),
2605 CWX | CWY | CWWidth | CWHeight);
2606
2607 EXPECT_THAT (mTestWindow, HasGeometry (Display (),
2608 AbsoluteWindowGeometry,
2609 ct::WINDOW_X + newExtents.left,
2610 ct::WINDOW_Y + newExtents.right,
2611 ct::WINDOW_WIDTH - (newExtents.left +
2612 newExtents.right),
2613 ct::WINDOW_HEIGHT - (newExtents.top +
2614 newExtents.bottom),
2615 _));
2616}
2617
2618TEST_P (PixmapDecorationAdjustment, AdjustRestoredWindowInputNoMoveClient)
2619{
2620 decor_extents_t newExtents = GetParam ();
2621
2622 ReconfigureDecoration (Display (),
2623 mTestWindow,
2624 mTestWindowDecoration,
2625 windowDecorations[mTestWindow],
2626 DecorationExtents (1, 1, 1, 1),
2627 newExtents);
2628
2629 EXPECT_THAT (mTestWindow, HasGeometry (Display (),
2630 AbsoluteWindowGeometry,
2631 ct::WINDOW_X + 1,
2632 ct::WINDOW_Y + 1,
2633 _,
2634 _,
2635 _));
2636}
2637
2638decor_extents_t AdjustmentExtents[] =
2639{
2640 DecorationExtents (2, 0, 0, 0),
2641 DecorationExtents (0, 2, 0, 0),
2642 DecorationExtents (0, 0, 2, 0),
2643 DecorationExtents (0, 0, 0, 2)
2644};
2645
2646INSTANTIATE_TEST_CASE_P (AdjustmentExtents,
2647 PixmapDecorationAdjustment,
2648 ValuesIn (AdjustmentExtents));
20042649
=== modified file 'tests/system/xorg-gtest/tests/compiz_xorg_gtest_configure_window.cpp'
--- tests/system/xorg-gtest/tests/compiz_xorg_gtest_configure_window.cpp 2013-04-03 08:46:17 +0000
+++ tests/system/xorg-gtest/tests/compiz_xorg_gtest_configure_window.cpp 2013-06-22 14:36:23 +0000
@@ -55,25 +55,6 @@
55 return ct::AdvanceToNextEventOnSuccess (d, r);55 return ct::AdvanceToNextEventOnSuccess (d, r);
56}56}
5757
58Window GetImmediateParent (Display *display,
59 Window w,
60 Window &rootReturn)
61{
62 Window parentReturn = w;
63 Window *childrenReturn;
64 unsigned int nChildrenReturn;
65
66 XQueryTree (display,
67 w,
68 &rootReturn,
69 &parentReturn,
70 &childrenReturn,
71 &nChildrenReturn);
72 XFree (childrenReturn);
73
74 return parentReturn;
75}
76
7758
78Window GetTopParent (Display *display,59Window GetTopParent (Display *display,
79 Window w)60 Window w)
@@ -86,9 +67,9 @@
86 {67 {
87 lastParent = parentReturn;68 lastParent = parentReturn;
8869
89 parentReturn = GetImmediateParent (display,70 parentReturn = ct::GetImmediateParent (display,
90 lastParent,71 lastParent,
91 rootReturn);72 rootReturn);
92 73
93 } while (parentReturn != rootReturn);74 } while (parentReturn != rootReturn);
9475
@@ -616,7 +597,7 @@
616597
617 /* Wrapper geometry is extents.xy, size.wh */598 /* Wrapper geometry is extents.xy, size.wh */
618 Window root;599 Window root;
619 Window wrapper = GetImmediateParent (dpy, w.client, root);600 Window wrapper = ct::GetImmediateParent (dpy, w.client, root);
620 ASSERT_TRUE (VerifyWindowSize (wrapper,601 ASSERT_TRUE (VerifyWindowSize (wrapper,
621 left,602 left,
622 top,603 top,
@@ -697,7 +678,7 @@
697678
698 /* Wrapper geometry is extents.xy, size.wh */679 /* Wrapper geometry is extents.xy, size.wh */
699 Window root;680 Window root;
700 Window wrapper = GetImmediateParent (dpy, client, root);681 Window wrapper = ct::GetImmediateParent (dpy, client, root);
701 ASSERT_TRUE (VerifyWindowSize (wrapper,682 ASSERT_TRUE (VerifyWindowSize (wrapper,
702 left,683 left,
703 top,684 top,
@@ -752,7 +733,7 @@
752733
753 /* Wrapper geometry is extents.xy, size.wh */734 /* Wrapper geometry is extents.xy, size.wh */
754 Window root;735 Window root;
755 Window wrapper = GetImmediateParent (dpy, client, root);736 Window wrapper = ct::GetImmediateParent (dpy, client, root);
756 ASSERT_TRUE (VerifyWindowSize (wrapper,737 ASSERT_TRUE (VerifyWindowSize (wrapper,
757 left,738 left,
758 top,739 top,
759740
=== modified file 'tests/xorg-gtest/include/compiz-xorg-gtest.h'
--- tests/xorg-gtest/include/compiz-xorg-gtest.h 2013-06-10 08:43:28 +0000
+++ tests/xorg-gtest/include/compiz-xorg-gtest.h 2013-06-22 14:36:23 +0000
@@ -122,6 +122,9 @@
122 const unsigned int WINDOW_HEIGHT = 480;122 const unsigned int WINDOW_HEIGHT = 480;
123123
124 Window CreateNormalWindow (Display *dpy);124 Window CreateNormalWindow (Display *dpy);
125 Window GetImmediateParent (Display *display,
126 Window w,
127 Window &rootReturn);
125128
126 std::list <Window> NET_CLIENT_LIST_STACKING (Display *);129 std::list <Window> NET_CLIENT_LIST_STACKING (Display *);
127 bool AdvanceToNextEventOnSuccess (Display *dpy,130 bool AdvanceToNextEventOnSuccess (Display *dpy,
128131
=== modified file 'tests/xorg-gtest/src/compiz-xorg-gtest.cpp'
--- tests/xorg-gtest/src/compiz-xorg-gtest.cpp 2013-04-15 13:09:33 +0000
+++ tests/xorg-gtest/src/compiz-xorg-gtest.cpp 2013-06-22 14:36:23 +0000
@@ -85,6 +85,26 @@
85 return w;85 return w;
86}86}
8787
88Window
89ct::GetImmediateParent (Display *display,
90 Window w,
91 Window &rootReturn)
92{
93 Window parentReturn = w;
94 Window *childrenReturn;
95 unsigned int nChildrenReturn;
96
97 XQueryTree (display,
98 w,
99 &rootReturn,
100 &parentReturn,
101 &childrenReturn,
102 &nChildrenReturn);
103 XFree (childrenReturn);
104
105 return parentReturn;
106}
107
88bool108bool
89ct::AdvanceToNextEventOnSuccess (Display *dpy,109ct::AdvanceToNextEventOnSuccess (Display *dpy,
90 bool waitResult)110 bool waitResult)

Subscribers

People subscribed via source and target branches

to all changes: