Merge lp:~compiz-team/compiz/compiz.fix_1195522 into lp:compiz/0.9.10

Proposed by Sam Spilsbury
Status: Merged
Approved by: Brandon Schaefer
Approved revision: 3755
Merged at revision: 3751
Proposed branch: lp:~compiz-team/compiz/compiz.fix_1195522
Merge into: lp:compiz/0.9.10
Diff against target: 2357 lines (+758/-645)
24 files modified
.bzrignore (+1/-0)
plugins/decor/src/decor.cpp (+47/-132)
plugins/decor/src/decor.h (+5/-1)
plugins/decor/tests/acceptance/xorg-gtest/CMakeLists.txt (+1/-1)
plugins/decor/tests/acceptance/xorg-gtest/compiz_decor_acceptance_tests.cpp (+74/-212)
plugins/move/src/move.cpp (+19/-9)
plugins/opengl/src/paint.cpp (+1/-1)
plugins/place/src/constrain-to-workarea/include/constrain-to-workarea.h (+3/-6)
plugins/place/src/constrain-to-workarea/src/constrain-to-workarea.cpp (+25/-49)
plugins/place/src/constrain-to-workarea/tests/constrain-to-workarea/src/test-place-constrain-to-workarea.cpp (+4/-57)
plugins/place/src/place.cpp (+15/-16)
src/event.cpp (+7/-2)
src/plugin.cpp (+15/-2)
src/plugin/tests/test-plugin.cpp (+40/-0)
src/window.cpp (+71/-58)
src/window/extents/src/windowextents.cpp (+10/-0)
tests/manual/README.txt (+9/-0)
tests/manual/plugins/decor.txt (+40/-0)
tests/system/xorg-gtest/tests/compiz_xorg_gtest_configure_window.cpp (+91/-73)
tests/xorg-gtest/CMakeLists.txt (+2/-1)
tests/xorg-gtest/include/compiz-xorg-gtest.h (+79/-3)
tests/xorg-gtest/plugins/testhelper/src/testhelper.cpp (+5/-8)
tests/xorg-gtest/src/compiz-xorg-gtest-config.h.in (+2/-1)
tests/xorg-gtest/src/compiz-xorg-gtest.cpp (+192/-13)
To merge this branch: bzr merge lp:~compiz-team/compiz/compiz.fix_1195522
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
MC Return Approve
Brandon Schaefer (community) Approve
Andrea Azzarone Pending
Compiz Maintainers Pending
Review via email: mp+171944@code.launchpad.net

Commit message

Unrevert 3728, fix failing tests.

Change the behaviour of undecorating windows.

Previously when a window was undecorated, we would shift it back to an appropriate position according to its gravity member. That behaviour was problematic because in the StaticGravity case the window has to just stay in the same place. But then if you had a window with StaticGravity which then did get a decoration and later removed it, it would be placed as though it was decorated and appear to be in the wrong place.

The correct behaviour is to place all windows as though they have decorations, and then when decorations are removed, to move the window back to the corner as indicated in its gravity and then expand its size to cover the obscured regions no longer hidden because the decorations went away.

(LP: #1165343).

  1. Completely remove decorOffsetMove and other related code from
     decor.cpp. Put the logic to handle the window->input () - window->border ()
     placement offset inside of setWindowFrameExtents instead. Now the window
     will always be offset from its original non-decorated position to the new
     decorated position, rather than having to guess between decoration sizes.
  2. Make saveGeometry and restoreGeometry work relative to window->border ()
     as opposed to including it in the saved geometry. It is possible that the
     border size might change during maximization, as such, we don't want to
     save the position with the border before maximizing. Instead save the position
     as if it were never decorated so that when the window is restored it can be
     restored to its original position and then adjusted for its new border size.
  3. Fix a few typoes in the tests.
  4. Moved some commonly used matchers into compiz::testing
  5. Make COMPIZ_PLUGIN_DIR accept multiple directories and look in each one
     of them for the plugin
  6. Set COMPIZ_PLUGIN_DIR appropriately for each plugin that we wish to load
     on startup so that we load locally built plugins as opposed to installed
     ones.
  7. Uncomment compiz_discover_tests for the acceptance tests. Now they are
     run by default.

(LP: #1195522)

Description of the change

Unrevert 3728, fix failing tests.

Change the behaviour of undecorating windows.

Previously when a window was undecorated, we would shift it back to an appropriate position according to its gravity member. That behaviour was problematic because in the StaticGravity case the window has to just stay in the same place. But then if you had a window with StaticGravity which then did get a decoration and later removed it, it would be placed as though it was decorated and appear to be in the wrong place.

The correct behaviour is to place all windows as though they have decorations, and then when decorations are removed, to move the window back to the corner as indicated in its gravity and then expand its size to cover the obscured regions no longer hidden because the decorations went away.

(LP: #1165343).

  1. Completely remove decorOffsetMove and other related code from
     decor.cpp. Put the logic to handle the window->input () - window->border ()
     placement offset inside of setWindowFrameExtents instead. Now the window
     will always be offset from its original non-decorated position to the new
     decorated position, rather than having to guess between decoration sizes.
  2. Make saveGeometry and restoreGeometry work relative to window->border ()
     as opposed to including it in the saved geometry. It is possible that the
     border size might change during maximization, as such, we don't want to
     save the position with the border before maximizing. Instead save the position
     as if it were never decorated so that when the window is restored it can be
     restored to its original position and then adjusted for its new border size.
  3. Fix a few typoes in the tests.
  4. Moved some commonly used matchers into compiz::testing
  5. Make COMPIZ_PLUGIN_DIR accept multiple directories and look in each one
     of them for the plugin
  6. Set COMPIZ_PLUGIN_DIR appropriately for each plugin that we wish to load
     on startup so that we load locally built plugins as opposed to installed
     ones.
  7. Uncomment compiz_discover_tests for the acceptance tests. Now they are
     run by default.

(LP: #1195522)

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

368 + int GetEventMask ();

Const?

The following tests FAILED:
 1481 - PixmapDecoratedWindowAcceptance.MaximizeBorderExtentsOnMaximize (Failed)
 1482 - PixmapDecoratedWindowAcceptance.MaximizeBorderExtentsOnVertMaximize (Failed)
 1483 - PixmapDecoratedWindowAcceptance.MaximizeBorderExtentsOnHorzMaximize (Failed)
 1484 - PixmapDecoratedWindowAcceptance.MaximizeFrameWindowSizeEqOutputSize (Failed)
 1485 - PixmapDecoratedWindowAcceptance.VertMaximizeFrameWindowSizeEqOutputYHeight (Failed)
 1486 - PixmapDecoratedWindowAcceptance.HorzMaximizeFrameWindowSizeEqOutputXWidth (Failed)
 1487 - PixmapDecoratedWindowAcceptance.VertMaximizeFrameWindowSizeSameXWidth (Failed)
 1488 - PixmapDecoratedWindowAcceptance.HorzMaximizeFrameWindowSizeSameYHeight (Failed)
 1489 - PixmapDecoratedWindowAcceptance.UndecoratedWindowExpandToOrigSize (Failed)
 1490 - PixmapDecoratedWindowAcceptance.UndecorateStaticGravityWindow (Failed)

Note this is just with a compiled branch...though it shoudn't depend on if I have the branch running or not if they are unit tests.

        Start 1451: AdjustmentExtents/PixmapDecorationAdjustment.AdjustRestoredWindowBorderShrinkClient/0

This test hangs sometimes forever. (At lease as far as im willing to let it sit :)

        Start 1485: PixmapDecoratedWindowAcceptance.VertMaximizeFrameWindowSizeEqOutputYHeight

Then this wont hung...as well as some others :)...not entirely sure why.

Still have some more reviewing to go :)

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

> 368 + int GetEventMask ();
>
> Const?

Yeah, I can fix that, cheers.

>
> The following tests FAILED:
> 1481 - PixmapDecoratedWindowAcceptance.MaximizeBorderExtentsOnMaximize
> (Failed)
> 1482 -
> PixmapDecoratedWindowAcceptance.MaximizeBorderExtentsOnVertMaximize (Failed)
> 1483 -
> PixmapDecoratedWindowAcceptance.MaximizeBorderExtentsOnHorzMaximize (Failed)
> 1484 -
> PixmapDecoratedWindowAcceptance.MaximizeFrameWindowSizeEqOutputSize (Failed)
> 1485 -
> PixmapDecoratedWindowAcceptance.VertMaximizeFrameWindowSizeEqOutputYHeight
> (Failed)
> 1486 -
> PixmapDecoratedWindowAcceptance.HorzMaximizeFrameWindowSizeEqOutputXWidth
> (Failed)
> 1487 -
> PixmapDecoratedWindowAcceptance.VertMaximizeFrameWindowSizeSameXWidth (Failed)
> 1488 -
> PixmapDecoratedWindowAcceptance.HorzMaximizeFrameWindowSizeSameYHeight
> (Failed)
> 1489 -
> PixmapDecoratedWindowAcceptance.UndecoratedWindowExpandToOrigSize (Failed)
> 1490 - PixmapDecoratedWindowAcceptance.UndecorateStaticGravityWindow
> (Failed)
>
> Note this is just with a compiled branch...though it shoudn't depend on if I
> have the branch running or not if they are unit tests.
>
> Start 1451: AdjustmentExtents/PixmapDecorationAdjustment.AdjustRestore
> dWindowBorderShrinkClient/0
>
> This test hangs sometimes forever. (At lease as far as im willing to let it
> sit :)
>
> Start 1485:
> PixmapDecoratedWindowAcceptance.VertMaximizeFrameWindowSizeEqOutputYHeight
>
> Then this wont hung...as well as some others :)...not entirely sure why.
>
> Still have some more reviewing to go :)

I've had some trouble with llvmpipe hanging on the tests. My plan is to make decor not depend on opengl and drop in a "fakecompositor" plugin instead which allows us to use the pixmap decorations without drawing anything.

... try running them when your system has cooled off a bit. I'll remove my local installation and check if there's some kind of hidden dependency but there shouldn't be.

Revision history for this message
MC Return (mc-return) wrote :

Thanks a lot for this, Sam.
Your last version in r3278 already brought massive improvements, especially when running Emerald.

I am quite sure that this one will finally get rid of all decor problems.
Will test this ASAP.

Revision history for this message
MC Return (mc-return) wrote :

First review:

726 + /* As the window is shrunk to accomadate the border size, we must subtract

should be (typo):

726 + /* As the window is shrunk to accommodate the border size, we must subtract

===

738 + ct::WINDOW_WIDTH - shrink.width () + size.width (),
739 + ct::WINDOW_HEIGHT - shrink.height () + size.height ());

795 + ct::WINDOW_WIDTH - shrink.width () + size.width (),
796 + ct::WINDOW_HEIGHT - shrink.height () + size.height (),

I would align those (just a suggestion, no real need to fix):

738 + ct::WINDOW_WIDTH - shrink.width () + size.width (),
739 + ct::WINDOW_HEIGHT - shrink.height () + size.height ());

===

You could remove the brackets here:

832 + xwc.x = xRoot - (width / 2);

855 + xwc.x = xRoot - (width / 2);

===

I guess this was just an indentation fix ?

871 - gw->priv->configureLock->release ();
872 + gw->priv->configureLock->release ();

===

The rest LGTM also.
As this touches many source-files it is not really easy to manually test though, but the old version of this was already great and now this additionally has massive test coverage, so "Approve" from me.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

> First review:
>
> 726 + /* As the window is shrunk to accomadate the border size, we must
> subtract
>
> should be (typo):
>
> 726 + /* As the window is shrunk to accommodate the border size, we
> must subtract

Fixed.

>
> I guess this was just an indentation fix ?
>
> 871 - gw->priv->configureLock->release ();
> 872 + gw->priv->configureLock->release ();
>
> ===

Pretty much

>
> The rest LGTM also.
> As this touches many source-files it is not really easy to manually test
> though, but the old version of this was already great and now this
> additionally has massive test coverage, so "Approve" from me.

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

Note: I've removed the acceptance tests from the CI target as llvmpipe does not work correctly there. We'll re-enable them once we can run the tests without llvmpipe.

Revision history for this message
MC Return (mc-return) wrote :

I would say -> let's give it a try.
With the PPAs in place we will notice possible regressions early and can combat them then, if any will occur, which I doubt to happen...

The final decision to merge is yours. +1 from me. :)

review: Approve
Revision history for this message
MC Return (mc-return) wrote :

One note:
If r3747 of this MP ( http://bazaar.launchpad.net/~compiz-team/compiz/compiz.fix_1195522/revision/3747 ) fixes LP: #1165343, shouldn't we link this branch to the bug report then and add the bug number to the main commit message ?

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Your branch hates me:

The following tests FAILED:
 1481 - PixmapDecoratedWindowAcceptance.MaximizeBorderExtentsOnMaximize (Failed)
 1482 - PixmapDecoratedWindowAcceptance.MaximizeBorderExtentsOnVertMaximize (Failed)
 1483 - PixmapDecoratedWindowAcceptance.MaximizeBorderExtentsOnHorzMaximize (Failed)
 1484 - PixmapDecoratedWindowAcceptance.MaximizeFrameWindowSizeEqOutputSize (Failed)
 1485 - PixmapDecoratedWindowAcceptance.VertMaximizeFrameWindowSizeEqOutputYHeight (Failed)
 1486 - PixmapDecoratedWindowAcceptance.HorzMaximizeFrameWindowSizeEqOutputXWidth (Failed)
 1487 - PixmapDecoratedWindowAcceptance.VertMaximizeFrameWindowSizeSameXWidth (Failed)
 1488 - PixmapDecoratedWindowAcceptance.HorzMaximizeFrameWindowSizeSameYHeight (Failed)
 1489 - PixmapDecoratedWindowAcceptance.UndecoratedWindowExpandToOrigSize (Failed)
 1490 - PixmapDecoratedWindowAcceptance.UndecorateStaticGravityWindow (Failed)
 1494 - CompizXorgSystemStackingTest.TestSetup (Failed)

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

I need to fix my system up though...

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

After talking with Sam its turning out that the tests failures are due to llvmpipe and some timeout problems. Since this branch fixes some blockers, and each failing tests passes when ran individually, Im approving this branch.

The tests do need to be fixed up, but lets get the blockers fixed first :)

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

Fix typo

Revision history for this message
MC Return (mc-return) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file '.bzrignore'
--- .bzrignore 1970-01-01 00:00:00 +0000
+++ .bzrignore 2013-06-29 07:09:28 +0000
@@ -0,0 +1,1 @@
1.bzr-repo
02
=== modified file 'plugins/decor/src/decor.cpp'
--- plugins/decor/src/decor.cpp 2013-06-07 05:51:45 +0000
+++ plugins/decor/src/decor.cpp 2013-06-29 07:09:28 +0000
@@ -1147,31 +1147,6 @@
1147}1147}
11481148
1149/*1149/*
1150 * decorOffsetMove
1151 *
1152 * Function called on a timer (to avoid calling configureXWindow from
1153 * within a ::moveNotify) which actually moves the window by the offset
1154 * specified in the xwc. Also sends a notification that the window
1155 * was decorated
1156 *
1157 */
1158static bool
1159decorOffsetMove (CompWindow *w, XWindowChanges xwc, unsigned int mask)
1160{
1161 CompOption::Vector o (1);
1162
1163 o.at (0).setName ("window", CompOption::TypeInt);
1164 o.at (0).value ().set ((int) w->id ());
1165
1166 xwc.x += w->serverGeometry ().x ();
1167 xwc.y += w->serverGeometry ().y ();
1168
1169 w->configureXWindow (mask, &xwc);
1170 screen->handleCompizEvent ("decor", "window_decorated", o);
1171 return false;
1172}
1173
1174/*
1175 * DecorWindow::matchType1150 * DecorWindow::matchType
1176 *1151 *
1177 * Converts libdecoration window types packed1152 * Converts libdecoration window types packed
@@ -1507,60 +1482,6 @@
1507 return decoration;1482 return decoration;
1508}1483}
15091484
1510void
1511DecorWindow::moveDecoratedWindowBy (const CompPoint &movement,
1512 bool instant)
1513{
1514 /* Need to actually move the window */
1515 if (window->placed () && !window->overrideRedirect () &&
1516 (movement.x () || movement.y ()))
1517 {
1518 XWindowChanges xwc;
1519 unsigned int mask = CWX | CWY;
1520
1521 memset (&xwc, 0, sizeof (XWindowChanges));
1522
1523 /* Grab the geometry last sent to server at configureXWindow
1524 * time and not here since serverGeometry may be updated by
1525 * the time that we do call configureXWindow */
1526 xwc.x = movement.x ();
1527 xwc.y = movement.y ();
1528
1529 /* Except if it's fullscreen, maximized or such */
1530 if (window->state () & CompWindowStateFullscreenMask)
1531 mask &= ~(CWX | CWY);
1532
1533 if (window->state () & CompWindowStateMaximizedHorzMask)
1534 mask &= ~CWX;
1535
1536 if (window->state () & CompWindowStateMaximizedVertMask)
1537 mask &= ~CWY;
1538
1539 if (window->saveMask () & CWX)
1540 window->saveWc ().x += movement.x ();
1541
1542 if (window->saveMask () & CWY)
1543 window->saveWc ().y += movement.y ();
1544
1545 if (mask)
1546 {
1547 /* instant is only true in the case of
1548 * the destructor calling the update function so since it
1549 * is not safe to put the function in a timer (since
1550 * it will get unref'd on the vtable destruction) we
1551 * need to do it immediately
1552 *
1553 * FIXME: CompTimer should really be PIMPL and allow
1554 * refcounting in case we need to keep it alive
1555 */
1556 if (instant)
1557 decorOffsetMove (window, xwc, mask);
1558 else
1559 moveUpdate.start (boost::bind (decorOffsetMove, window, xwc, mask), 0);
1560 }
1561 }
1562}
1563
1564namespace1485namespace
1565{1486{
1566bool1487bool
@@ -1568,14 +1489,30 @@
1568 bool shadowOnly,1489 bool shadowOnly,
1569 bool isSwitcher)1490 bool isSwitcher)
1570{1491{
1571 const bool visible = (w->frame () ||1492 const bool frameOrUnmapReference = (w->frame () ||
1572 w->hasUnmapReference ());1493 w->hasUnmapReference ());
1573 const bool realDecoration = visible && !shadowOnly;1494 const bool realDecoration = frameOrUnmapReference && !shadowOnly;
1574 const bool forceDecoration = isSwitcher;1495 const bool forceDecoration = isSwitcher;
15751496
1576 return realDecoration || forceDecoration;1497 return realDecoration || forceDecoration;
1577}1498}
1578}1499
1500/*
1501 * notifyDecoration
1502 *
1503 * Notify other plugins that the window is now fully decorated
1504 */
1505void notifyDecoration (CompWindow *window)
1506{
1507 CompOption::Vector o (1);
1508
1509 o.at (0).setName ("window", CompOption::TypeInt);
1510 o.at (0).value ().set ((int) window->id ());
1511
1512 screen->handleCompizEvent ("decor", "window_decorated", o);
1513}
1514}
1515
1579/*1516/*
1580 * DecorWindow::update1517 * DecorWindow::update
1581 * This is the master function for managing decorations on windows1518 * This is the master function for managing decorations on windows
@@ -1616,7 +1553,8 @@
1616DecorWindow::update (bool allowDecoration)1553DecorWindow::update (bool allowDecoration)
1617{1554{
1618 Decoration::Ptr old, decoration;1555 Decoration::Ptr old, decoration;
1619 CompPoint oldShift, movement;1556 CompPoint movement;
1557 CompSize sizeDelta;
16201558
1621 if (wd)1559 if (wd)
1622 old = wd->decor;1560 old = wd->decor;
@@ -1625,6 +1563,7 @@
16251563
1626 bool shadowOnly = bareDecorationOnly ();1564 bool shadowOnly = bareDecorationOnly ();
1627 bool decorate = shouldDecorateWindow (window, shadowOnly, isSwitcher);1565 bool decorate = shouldDecorateWindow (window, shadowOnly, isSwitcher);
1566 unsigned int decorMaximizeState = window->state () & MAXIMIZE_STATE;
16281567
1629 if (decorate || frameExtentsRequested)1568 if (decorate || frameExtentsRequested)
1630 {1569 {
@@ -1647,16 +1586,13 @@
1647 /* Don't bother going any further if1586 /* Don't bother going any further if
1648 * this window is going to get the same1587 * this window is going to get the same
1649 * decoration, just use the old one */1588 * decoration, just use the old one */
1650 if (decoration == old)1589 if (decoration == old &&
1590 lastMaximizedStateDecorated == decorMaximizeState)
1651 return false;1591 return false;
16521592
1653 /* Determine how much we moved the window for the old1593 /* Destroy the old WindowDecoration */
1654 * decoration and save that, also destroy the old
1655 * WindowDecoration */
1656 if (old)1594 if (old)
1657 {1595 {
1658 oldShift = cwe::shift (window->border (), window->sizeHints ().win_gravity);
1659
1660 WindowDecoration::destroy (wd);1596 WindowDecoration::destroy (wd);
1661 wd = NULL;1597 wd = NULL;
1662 }1598 }
@@ -1672,13 +1608,15 @@
1672 /* Set extents based on maximize/unmaximize state1608 /* Set extents based on maximize/unmaximize state
1673 * FIXME: With the new type system, this should be1609 * FIXME: With the new type system, this should be
1674 * removed */1610 * removed */
1675 if ((window->state () & MAXIMIZE_STATE))1611 if (decorMaximizeState)
1676 window->setWindowFrameExtents (&decoration->maxBorder,1612 window->setWindowFrameExtents (&decoration->maxBorder,
1677 &decoration->maxInput);1613 &decoration->maxInput);
1678 else if (!window->hasUnmapReference ())1614 else if (!window->hasUnmapReference ())
1679 window->setWindowFrameExtents (&decoration->border,1615 window->setWindowFrameExtents (&decoration->border,
1680 &decoration->input);1616 &decoration->input);
16811617
1618 lastMaximizedStateDecorated = decorMaximizeState;
1619
1682 /* This window actually needs its decoration contents updated1620 /* This window actually needs its decoration contents updated
1683 * as it was actually visible */1621 * as it was actually visible */
1684 if (decorate ||1622 if (decorate ||
@@ -1694,9 +1632,6 @@
1694 return false;1632 return false;
1695 }1633 }
16961634
1697 movement = cwe::shift (window->border (), window->sizeHints ().win_gravity);
1698 movement -= oldShift;
1699
1700 window->updateWindowOutputExtents ();1635 window->updateWindowOutputExtents ();
17011636
1702 updateReg = true;1637 updateReg = true;
@@ -1724,8 +1659,6 @@
1724 memset (&emptyExtents, 0, sizeof (CompWindowExtents));1659 memset (&emptyExtents, 0, sizeof (CompWindowExtents));
17251660
1726 window->setWindowFrameExtents (&emptyExtents, &emptyExtents);1661 window->setWindowFrameExtents (&emptyExtents, &emptyExtents);
1727
1728 movement -= oldShift;
1729 }1662 }
17301663
1731 /* We need to damage the current output extents1664 /* We need to damage the current output extents
@@ -1738,8 +1671,7 @@
1738 updateGroupShadows ();1671 updateGroupShadows ();
1739 }1672 }
17401673
1741 moveDecoratedWindowBy (movement,1674 notifyDecoration (window);
1742 !allowDecoration);
17431675
1744 return true;1676 return true;
1745}1677}
@@ -2280,6 +2212,20 @@
2280}2212}
22812213
2282/*2214/*
2215 * DecorWindow::place
2216 *
2217 * Update any windows just before placement
2218 * so that placement algorithms will have the
2219 * border size at place-time
2220 */
2221bool
2222DecorWindow::place (CompPoint &pos)
2223{
2224 update (true);
2225 return window->place (pos);
2226}
2227
2228/*
2283 * DecorWindow::windowNotify2229 * DecorWindow::windowNotify
2284 *2230 *
2285 * Window event notification handler. On various2231 * Window event notification handler. On various
@@ -2924,13 +2870,7 @@
2924 shading = false;2870 shading = false;
2925 unshading = false;2871 unshading = false;
2926 }2872 }
2927 /* FIXME: we should not need a timer for calling decorWindowUpdate,2873
2928 and only call updateWindowDecorationScale if decorWindowUpdate
2929 returns false. Unfortunately, decorWindowUpdate may call
2930 updateWindowOutputExtents, which may call WindowResizeNotify. As
2931 we never should call a wrapped function that's currently
2932 processed, we need the timer for the moment. updateWindowOutputExtents
2933 should be fixed so that it does not emit a resize notification. */
2934 updateMatrix = true;2874 updateMatrix = true;
2935 updateReg = true;2875 updateReg = true;
29362876
@@ -2955,33 +2895,7 @@
2955void2895void
2956DecorWindow::stateChangeNotify (unsigned int lastState)2896DecorWindow::stateChangeNotify (unsigned int lastState)
2957{2897{
2958 if (wd && wd->decor)2898 update (true);
2959 {
2960 CompPoint oldShift = compiz::window::extents::shift (window->border (), window->sizeHints ().win_gravity);
2961
2962
2963 if ((window->state () & MAXIMIZE_STATE))
2964 window->setWindowFrameExtents (&wd->decor->maxBorder,
2965 &wd->decor->maxInput);
2966 else
2967 window->setWindowFrameExtents (&wd->decor->border,
2968 &wd->decor->input);
2969
2970 /* Since we immediately update the frame extents, we must
2971 * also update the stored saved window geometry in order
2972 * to prevent the window from shifting back too far once
2973 * unmaximized */
2974
2975 CompPoint movement = compiz::window::extents::shift (window->border (), window->sizeHints ().win_gravity) - oldShift;
2976
2977 if (window->saveMask () & CWX)
2978 window->saveWc ().x += movement.x ();
2979
2980 if (window->saveMask () & CWY)
2981 window->saveWc ().y += movement.y ();
2982
2983 updateFrame ();
2984 }
29852899
2986 window->stateChangeNotify (lastState);2900 window->stateChangeNotify (lastState);
2987}2901}
@@ -3218,7 +3132,8 @@
3218 mClipGroup (NULL),3132 mClipGroup (NULL),
3219 mOutputRegion (window->outputRect ()),3133 mOutputRegion (window->outputRect ()),
3220 mInputRegion (window->inputRect ()),3134 mInputRegion (window->inputRect ()),
3221 mRequestor (screen->dpy (), w->id (), &decor)3135 mRequestor (screen->dpy (), w->id (), &decor),
3136 lastMaximizedStateDecorated (0)
3222{3137{
3223 WindowInterface::setHandler (window);3138 WindowInterface::setHandler (window);
32243139
32253140
=== modified file 'plugins/decor/src/decor.h'
--- plugins/decor/src/decor.h 2013-06-07 05:51:45 +0000
+++ plugins/decor/src/decor.h 2013-06-29 07:09:28 +0000
@@ -293,6 +293,8 @@
293293
294 bool damageRect (bool, const CompRect &);294 bool damageRect (bool, const CompRect &);
295295
296 bool place (CompPoint &pos);
297
296 bool glDraw (const GLMatrix &, const GLWindowPaintAttrib &,298 bool glDraw (const GLMatrix &, const GLWindowPaintAttrib &,
297 const CompRegion &, unsigned int);299 const CompRegion &, unsigned int);
298 void glDecorate (const GLMatrix &, const GLWindowPaintAttrib &,300 void glDecorate (const GLMatrix &, const GLWindowPaintAttrib &,
@@ -380,13 +382,15 @@
380382
381 X11DecorPixmapRequestor mRequestor;383 X11DecorPixmapRequestor mRequestor;
382384
385 unsigned int lastMaximizedStateDecorated;
386
383 private:387 private:
384388
385 bool bareDecorationOnly ();389 bool bareDecorationOnly ();
386 Decoration::Ptr findRealDecoration ();390 Decoration::Ptr findRealDecoration ();
387 Decoration::Ptr findBareDecoration ();391 Decoration::Ptr findBareDecoration ();
388 void moveDecoratedWindowBy (const CompPoint &movement,392 void moveDecoratedWindowBy (const CompPoint &movement,
389 bool instant);393 const CompSize &sizeDelta);
390};394};
391395
392class DecorPluginVTable :396class DecorPluginVTable :
393397
=== modified file 'plugins/decor/tests/acceptance/xorg-gtest/CMakeLists.txt'
--- plugins/decor/tests/acceptance/xorg-gtest/CMakeLists.txt 2013-06-22 12:27:36 +0000
+++ plugins/decor/tests/acceptance/xorg-gtest/CMakeLists.txt 2013-06-29 07:09:28 +0000
@@ -31,7 +31,7 @@
31 target_link_libraries (compiz_test_decor_acceptance31 target_link_libraries (compiz_test_decor_acceptance
32 ${COMPIZ_DECOR_ACCEPTANCE_TEST_LIBRARIES})32 ${COMPIZ_DECOR_ACCEPTANCE_TEST_LIBRARIES})
3333
34 # Not run by default yet until we're able to load plugins locally34 # Disabled until the tests can be run without opengl
35 #compiz_discover_tests (compiz_test_decor_acceptance WITH_XORG_GTEST)35 #compiz_discover_tests (compiz_test_decor_acceptance WITH_XORG_GTEST)
3636
37endif (BUILD_XORG_GTEST)37endif (BUILD_XORG_GTEST)
3838
=== 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-22 14:31:25 +0000
+++ plugins/decor/tests/acceptance/xorg-gtest/compiz_decor_acceptance_tests.cpp 2013-06-29 07:09:28 +0000
@@ -57,6 +57,10 @@
57using ::testing::WithParamInterface;57using ::testing::WithParamInterface;
58using ::testing::_;58using ::testing::_;
5959
60using ::compiz::testing::HasGeometry;
61using ::compiz::testing::RelativeWindowGeometry;
62using ::compiz::testing::AbsoluteWindowGeometry;
63
60class BaseDecorAcceptance :64class BaseDecorAcceptance :
61 public ct::AutostartCompizXorgSystemTestWithTestHelper65 public ct::AutostartCompizXorgSystemTestWithTestHelper
62{66{
@@ -78,6 +82,10 @@
78 Atom mDecorationTypeWindow;82 Atom mDecorationTypeWindow;
79 Atom mDecorationInputFrameAtom;83 Atom mDecorationInputFrameAtom;
80 Atom mDecorationOutputFrameAtom;84 Atom mDecorationOutputFrameAtom;
85
86 private:
87
88 int GetEventMask () const;
81};89};
8290
83BaseDecorAcceptance::BaseDecorAcceptance () :91BaseDecorAcceptance::BaseDecorAcceptance () :
@@ -92,6 +100,13 @@
92{100{
93}101}
94102
103int
104BaseDecorAcceptance::GetEventMask () const
105{
106 return ct::AutostartCompizXorgSystemTestWithTestHelper::GetEventMask () |
107 SubstructureNotifyMask;
108}
109
95void110void
96BaseDecorAcceptance::SetUp ()111BaseDecorAcceptance::SetUp ()
97{112{
@@ -151,9 +166,12 @@
151 ct::CompizProcess::PluginList baseList (Base::GetPluginList ());166 ct::CompizProcess::PluginList baseList (Base::GetPluginList ());
152 ct::CompizProcess::PluginList list;167 ct::CompizProcess::PluginList list;
153168
154 list.push_back ("composite");169 list.push_back (ct::CompizProcess::Plugin ("composite",
155 list.push_back ("opengl");170 ct::CompizProcess::Real));
156 list.push_back ("decor");171 list.push_back (ct::CompizProcess::Plugin ("opengl",
172 ct::CompizProcess::Real));
173 list.push_back (ct::CompizProcess::Plugin ("decor",
174 ct::CompizProcess::Real));
157175
158 for (ct::CompizProcess::PluginList::iterator it = baseList.begin ();176 for (ct::CompizProcess::PluginList::iterator it = baseList.begin ();
159 it != baseList.end ();177 it != baseList.end ();
@@ -1122,17 +1140,13 @@
1122 height,1140 height,
1123 mask);1141 mask);
11241142
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,1143 Advance (display,
1129 ct::WaitForEventOfTypeOnWindowMatching (display,1144 ct::WaitForEventOfTypeOnWindowMatching (display,
1130 window,1145 window,
1131 ConfigureNotify,1146 ConfigureNotify,
1132 -1,1147 -1,
1133 -1,1148 -1,
1134 matcher,1149 matcher));
1135 1000));
1136}1150}
11371151
1138void WaitForFrameExtents (Display *dpy,1152void WaitForFrameExtents (Display *dpy,
@@ -1729,9 +1743,6 @@
1729 Window window,1743 Window window,
1730 const FakeDecorPtr &decor)1744 const FakeDecorPtr &decor)
1731{1745{
1732 /* Wait for the frame extents to change */
1733 WaitForPropertyNotify (display, window, "_NET_FRAME_EXTENTS");
1734
1735 const CompPoint &framePos (decor->restoredFrameWindowOffset ());1746 const CompPoint &framePos (decor->restoredFrameWindowOffset ());
17361747
1737 /* Wait for the ConfigureNotify on the frame window1748 /* Wait for the ConfigureNotify on the frame window
@@ -1743,6 +1754,9 @@
1743 0,1754 0,
1744 0,1755 0,
1745 CWX | CWY);1756 CWX | CWY);
1757
1758 /* Wait for the frame extents to change */
1759 WaitForPropertyNotify (display, window, "_NET_FRAME_EXTENTS");
1746}1760}
17471761
1748void1762void
@@ -1802,6 +1816,8 @@
1802{1816{
1803 public:1817 public:
18041818
1819 PixmapDecoratedWindowAcceptance ();
1820
1805 virtual void SetUp ();1821 virtual void SetUp ();
1806 virtual void TearDown ();1822 virtual void TearDown ();
18071823
@@ -1809,12 +1825,19 @@
18091825
1810 protected:1826 protected:
18111827
1828 unsigned int RealDecorationActiveBorderExtent;
1829
1812 Window mTestWindow;1830 Window mTestWindow;
1813 Window mTestWindowParent;1831 Window mTestWindowParent;
18141832
1815 cdt::FakePixmapTypeDecoration::Ptr mTestWindowDecoration;1833 cdt::FakePixmapTypeDecoration::Ptr mTestWindowDecoration;
1816};1834};
18171835
1836PixmapDecoratedWindowAcceptance::PixmapDecoratedWindowAcceptance () :
1837 RealDecorationActiveBorderExtent (ActiveBorderExtent + 1)
1838{
1839}
1840
1818void1841void
1819PixmapDecoratedWindowAcceptance::SetUp ()1842PixmapDecoratedWindowAcceptance::SetUp ()
1820{1843{
@@ -1828,7 +1851,9 @@
1828 /* Start the decorator */1851 /* Start the decorator */
1829 SetUpDecorator ();1852 SetUpDecorator ();
18301853
1831 unsigned int ResBo = ActiveBorderExtent;1854 /* We need to change the border extent so that the window
1855 * will move from its position in the default decoration */
1856 unsigned int ResBo = RealDecorationActiveBorderExtent;
1832 unsigned int ResIn = ActiveInputExtent;1857 unsigned int ResIn = ActiveInputExtent;
1833 unsigned int MaxEx = MaximizedBorderExtent;1858 unsigned int MaxEx = MaximizedBorderExtent;
18341859
@@ -2077,167 +2102,6 @@
20772102
2078namespace2103namespace
2079{2104{
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
2125class WindowGeometryMatcher :
2126 public MatcherInterface <Window>
2127{
2128 public:
2129
2130 WindowGeometryMatcher (Display *dpy,
2131 RetrievalFunc func,
2132 const Matcher <int> &x,
2133 const Matcher <int> &y,
2134 const Matcher <unsigned int> &width,
2135 const Matcher <unsigned int> &height,
2136 const Matcher <unsigned int> &border);
2137
2138 bool MatchAndExplain (Window x, MatchResultListener *listener) const;
2139 void DescribeTo (std::ostream *os) const;
2140
2141 private:
2142
2143 Display *mDpy;
2144
2145 RetrievalFunc mFunc;
2146
2147 Matcher <int> mX;
2148 Matcher <int> mY;
2149 Matcher <unsigned int> mWidth;
2150 Matcher <unsigned int> mHeight;
2151 Matcher <unsigned int> mBorder;
2152};
2153
2154Matcher <Window>
2155HasGeometry (Display *dpy,
2156 RetrievalFunc func,
2157 const Matcher <int> &x,
2158 const Matcher <int> &y,
2159 const Matcher <unsigned int> &width,
2160 const Matcher <unsigned int> &height,
2161 const Matcher <unsigned int> &border)
2162{
2163 return MakeMatcher (new WindowGeometryMatcher (dpy,
2164 func,
2165 x,
2166 y,
2167 width,
2168 height,
2169 border));
2170}
2171}
2172
2173WindowGeometryMatcher::WindowGeometryMatcher (Display *dpy,
2174 RetrievalFunc func,
2175 const Matcher <int> &x,
2176 const Matcher <int> &y,
2177 const Matcher <unsigned int> &width,
2178 const Matcher <unsigned int> &height,
2179 const Matcher <unsigned int> &border) :
2180 mDpy (dpy),
2181 mFunc (func),
2182 mX (x),
2183 mY (y),
2184 mWidth (width),
2185 mHeight (height),
2186 mBorder (border)
2187{
2188}
2189
2190bool
2191WindowGeometryMatcher::MatchAndExplain (Window w,
2192 MatchResultListener *listener) const
2193{
2194 int x, y;
2195 unsigned int width, height, border;
2196
2197 mFunc (mDpy, w, x, y, width, height, border);
2198
2199 bool match = mX.MatchAndExplain (x, listener) &&
2200 mY.MatchAndExplain (y, listener) &&
2201 mWidth.MatchAndExplain (width, listener) &&
2202 mHeight.MatchAndExplain (height, listener) &&
2203 mBorder.MatchAndExplain (border, listener);
2204
2205 if (!match)
2206 {
2207 *listener << "Geometry:"
2208 << " x: " << x
2209 << " y: " << y
2210 << " width: " << width
2211 << " height: " << height
2212 << " border: " << border;
2213 }
2214
2215 return match;
2216}
2217
2218void
2219WindowGeometryMatcher::DescribeTo (std::ostream *os) const
2220{
2221 *os << "Window geometry matching :";
2222
2223 *os << std::endl << " - ";
2224 mX.DescribeTo (os);
2225
2226 *os << std::endl << " - ";
2227 mY.DescribeTo (os);
2228
2229 *os << std::endl << " - ";
2230 mWidth.DescribeTo (os);
2231
2232 *os << std::endl << " - ";
2233 mHeight.DescribeTo (os);
2234
2235 *os << std::endl << " - ";
2236 mBorder.DescribeTo (os);
2237}
2238
2239namespace
2240{
2241void WindowBorderPositionAttributes (Display *dpy,2105void WindowBorderPositionAttributes (Display *dpy,
2242 Window w,2106 Window w,
2243 XWindowAttributes &attrib,2107 XWindowAttributes &attrib,
@@ -2246,16 +2110,15 @@
2246{2110{
2247 XGetWindowAttributes (dpy, w, &attrib);2111 XGetWindowAttributes (dpy, w, &attrib);
22482112
2249 /* Remove border - input offset */2113 /* Remove input - border offset */
2250 attrib.x -= (ActiveBorderExtent - ActiveInputExtent);2114 attrib.x += (ActiveInputExtent - ActiveBorderExtent);
2251 attrib.y -= (ActiveBorderExtent - ActiveInputExtent);2115 attrib.y += (ActiveInputExtent - ActiveBorderExtent);
2252 attrib.width -= (ActiveBorderExtent - ActiveInputExtent) * 2;2116 attrib.width -= (ActiveInputExtent - ActiveBorderExtent) * 2;
2253 attrib.height -= (ActiveBorderExtent - ActiveInputExtent) * 2;2117 attrib.height -= (ActiveInputExtent - ActiveBorderExtent) * 2;
2254}2118}
2255}2119}
22562120
2257/* DISABLED - Upon maximization, x offset is 1, width offset is 10 */2121TEST_F (PixmapDecoratedWindowAcceptance, VertMaximizeFrameWindowSizeSameXWidth)
2258TEST_F (PixmapDecoratedWindowAcceptance, DISABLED_VertMaximizeFrameWindowSizeSameXWidth)
2259{2122{
2260 XWindowAttributes rootAttrib, attrib;2123 XWindowAttributes rootAttrib, attrib;
2261 XGetWindowAttributes (Display (), DefaultRootWindow (Display ()), &rootAttrib);2124 XGetWindowAttributes (Display (), DefaultRootWindow (Display ()), &rootAttrib);
@@ -2263,7 +2126,7 @@
2263 WindowBorderPositionAttributes (Display (),2126 WindowBorderPositionAttributes (Display (),
2264 mTestWindowParent,2127 mTestWindowParent,
2265 attrib,2128 attrib,
2266 ActiveBorderExtent,2129 RealDecorationActiveBorderExtent,
2267 ActiveInputExtent);2130 ActiveInputExtent);
22682131
2269 ChangeStateOfWindow (Display (),2132 ChangeStateOfWindow (Display (),
@@ -2293,8 +2156,7 @@
2293 _));2156 _));
2294}2157}
22952158
2296/* DISABLED - Upon maximization, y offset is 1, height offset is 10 */2159TEST_F (PixmapDecoratedWindowAcceptance, HorzMaximizeFrameWindowSizeSameYHeight)
2297TEST_F (PixmapDecoratedWindowAcceptance, DISABLED_HorzMaximizeFrameWindowSizeSameYHeight)
2298{2160{
2299 XWindowAttributes rootAttrib, attrib;2161 XWindowAttributes rootAttrib, attrib;
2300 XGetWindowAttributes (Display (), DefaultRootWindow (Display ()), &rootAttrib);2162 XGetWindowAttributes (Display (), DefaultRootWindow (Display ()), &rootAttrib);
@@ -2302,7 +2164,7 @@
2302 WindowBorderPositionAttributes (Display (),2164 WindowBorderPositionAttributes (Display (),
2303 mTestWindowParent,2165 mTestWindowParent,
2304 attrib,2166 attrib,
2305 ActiveBorderExtent,2167 RealDecorationActiveBorderExtent,
2306 ActiveInputExtent);2168 ActiveInputExtent);
23072169
2308 ChangeStateOfWindow (Display (),2170 ChangeStateOfWindow (Display (),
@@ -2356,12 +2218,7 @@
2356 _));2218 _));
2357}2219}
23582220
2359/* DISABLED - Ensure that a window with StaticGravity expands to its2221TEST_F (PixmapDecoratedWindowAcceptance, UndecorateStaticGravityWindow)
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{2222{
2366 XSizeHints hints;2223 XSizeHints hints;
23672224
@@ -2474,7 +2331,7 @@
2474 _));2331 _));
2475}2332}
24762333
2477TEST_P (PixmapDecorationAdjustment, DISABLED_AdjustRestoredWindowBorderShrinkClient)2334TEST_P (PixmapDecorationAdjustment, AdjustRestoredWindowBorderShrinkClient)
2478{2335{
2479 ReconfigureDecoration (Display (),2336 ReconfigureDecoration (Display (),
2480 mTestWindow,2337 mTestWindow,
@@ -2494,7 +2351,7 @@
2494 _));2351 _));
2495}2352}
24962353
2497TEST_P (PixmapDecorationAdjustment, DISABLED_ClientExpandsAsBorderShrinks)2354TEST_P (PixmapDecorationAdjustment, ClientExpandsAsBorderShrinks)
2498{2355{
2499 decor_extents_t newExtents = GetParam ();2356 decor_extents_t newExtents = GetParam ();
25002357
@@ -2523,7 +2380,7 @@
2523 _));2380 _));
2524}2381}
25252382
2526TEST_P (PixmapDecorationAdjustment, DISABLED_ClientExpandsAsBorderShrinksWhilstMaximized)2383TEST_P (PixmapDecorationAdjustment, ClientExpandsAsBorderShrinksWhilstMaximized)
2527{2384{
2528 decor_extents_t newExtents = GetParam ();2385 decor_extents_t newExtents = GetParam ();
25292386
@@ -2546,16 +2403,21 @@
2546 const CompPoint &off (mTestWindowDecoration->restoredFrameWindowOffset ());2403 const CompPoint &off (mTestWindowDecoration->restoredFrameWindowOffset ());
2547 const CompSize &size (mTestWindowDecoration->restoredDecorationSize ());2404 const CompSize &size (mTestWindowDecoration->restoredDecorationSize ());
25482405
2406 /* As the window is shrunk to accomodate the border size, we must subtract
2407 * the border from the original window size */
2408 CompSize shrink ((newExtents.left + newExtents.right),
2409 (newExtents.top + newExtents.bottom));
2410
2549 RestoreWindow (mTestWindow,2411 RestoreWindow (mTestWindow,
2550 ct::WINDOW_X - off.x (),2412 ct::WINDOW_X + off.x (),
2551 ct::WINDOW_Y - off.y (),2413 ct::WINDOW_Y + off.y (),
2552 ct::WINDOW_WIDTH + size.width (),2414 ct::WINDOW_WIDTH - shrink.width () + size.width (),
2553 ct::WINDOW_HEIGHT + size.height ());2415 ct::WINDOW_HEIGHT - shrink.height () + size.height ());
25542416
2555 EXPECT_THAT (mTestWindow, HasGeometry (Display (),2417 EXPECT_THAT (mTestWindow, HasGeometry (Display (),
2556 AbsoluteWindowGeometry,2418 AbsoluteWindowGeometry,
2557 ct::WINDOW_X + newExtents.left,2419 ct::WINDOW_X + newExtents.left,
2558 ct::WINDOW_Y + newExtents.right,2420 ct::WINDOW_Y + newExtents.top,
2559 ct::WINDOW_WIDTH - (newExtents.left +2421 ct::WINDOW_WIDTH - (newExtents.left +
2560 newExtents.right),2422 newExtents.right),
2561 ct::WINDOW_HEIGHT - (newExtents.top +2423 ct::WINDOW_HEIGHT - (newExtents.top +
@@ -2563,7 +2425,7 @@
2563 _));2425 _));
2564}2426}
25652427
2566TEST_P (PixmapDecorationAdjustment, DISABLED_ClientExpandsAsBorderShrinksWhilstUndecorated)2428TEST_P (PixmapDecorationAdjustment, ClientExpandsAsBorderShrinksWhilstUndecorated)
2567{2429{
2568 decor_extents_t newExtents = GetParam ();2430 decor_extents_t newExtents = GetParam ();
25692431
@@ -2574,16 +2436,11 @@
2574 DecorationExtents (10, 10, 10, 10),2436 DecorationExtents (10, 10, 10, 10),
2575 DecorationExtents (10, 10, 10, 10));2437 DecorationExtents (10, 10, 10, 10));
25762438
2439 /* When decorations are disabled on this window, the frame window
2440 * will retain the exact same size, as border == input in the previous
2441 * case. So there's no need to wait */
2577 DisallowDecorationsOnWindow (mTestWindow);2442 DisallowDecorationsOnWindow (mTestWindow);
25782443
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 waiting2444 /* Set the property on the window, then decorate without waiting
2588 * for a response we will continue to use the maximized window decoration */2445 * for a response we will continue to use the maximized window decoration */
2589 mTestWindowDecoration->changeRestoredBorder (newExtents);2446 mTestWindowDecoration->changeRestoredBorder (newExtents);
@@ -2596,18 +2453,23 @@
2596 const CompPoint &off (mTestWindowDecoration->restoredFrameWindowOffset ());2453 const CompPoint &off (mTestWindowDecoration->restoredFrameWindowOffset ());
2597 const CompSize &size (mTestWindowDecoration->restoredDecorationSize ());2454 const CompSize &size (mTestWindowDecoration->restoredDecorationSize ());
25982455
2456 /* As the window is shrunk to accomadate the border size, we must subtract
2457 * the border from the original window size */
2458 CompSize shrink ((newExtents.left + newExtents.right),
2459 (newExtents.top + newExtents.bottom));
2460
2599 WaitForConfigureOn (Display (),2461 WaitForConfigureOn (Display (),
2600 mTestWindowParent,2462 mTestWindowParent,
2601 ct::WINDOW_X - off.x (),2463 ct::WINDOW_X + off.x (),
2602 ct::WINDOW_Y - off.y (),2464 ct::WINDOW_Y + off.y (),
2603 ct::WINDOW_WIDTH + size.width (),2465 ct::WINDOW_WIDTH - shrink.width () + size.width (),
2604 ct::WINDOW_HEIGHT + size.height (),2466 ct::WINDOW_HEIGHT - shrink.height () + size.height (),
2605 CWX | CWY | CWWidth | CWHeight);2467 CWX | CWY | CWWidth | CWHeight);
26062468
2607 EXPECT_THAT (mTestWindow, HasGeometry (Display (),2469 EXPECT_THAT (mTestWindow, HasGeometry (Display (),
2608 AbsoluteWindowGeometry,2470 AbsoluteWindowGeometry,
2609 ct::WINDOW_X + newExtents.left,2471 ct::WINDOW_X + newExtents.left,
2610 ct::WINDOW_Y + newExtents.right,2472 ct::WINDOW_Y + newExtents.top,
2611 ct::WINDOW_WIDTH - (newExtents.left +2473 ct::WINDOW_WIDTH - (newExtents.left +
2612 newExtents.right),2474 newExtents.right),
2613 ct::WINDOW_HEIGHT - (newExtents.top +2475 ct::WINDOW_HEIGHT - (newExtents.top +
26142476
=== modified file 'plugins/move/src/move.cpp'
--- plugins/move/src/move.cpp 2013-05-09 13:43:07 +0000
+++ plugins/move/src/move.cpp 2013-06-29 07:09:28 +0000
@@ -395,18 +395,23 @@
395 {395 {
396 int width = w->serverGeometry ().width ();396 int width = w->serverGeometry ().width ();
397397
398 w->saveMask () |= CWX | CWY;
399
400 if (w->saveMask () & CWWidth)398 if (w->saveMask () & CWWidth)
401 width = w->saveWc ().width;399 width = w->saveWc ().width;
402400
403 w->saveWc ().x = xRoot - (width >> 1);
404 w->saveWc ().y = yRoot + (w->border ().top >> 1);
405
406 ms->x = ms->y = 0;401 ms->x = ms->y = 0;
407402
403 /* Get a lock on configure requests so that we can make
404 * any movement here atomic */
405 compiz::window::configure_buffers::ReleasablePtr lock (w->obtainLockOnConfigureRequests ());
406
408 w->maximize (0);407 w->maximize (0);
409408
409 XWindowChanges xwc;
410 xwc.x = xRoot - (width / 2);
411 xwc.y = yRoot + w->border ().top / 2;
412
413 w->configureXWindow (CWX | CWY, &xwc);
414
410 ms->snapOffY = ms->snapBackY;415 ms->snapOffY = ms->snapBackY;
411416
412 return;417 return;
@@ -440,13 +445,18 @@
440 if (w->saveMask () & CWWidth)445 if (w->saveMask () & CWWidth)
441 width = w->saveWc ().width;446 width = w->saveWc ().width;
442447
443 w->saveWc ().x = xRoot - (width >> 1);448 /* Get a lock on configure requests so that we can make
444 w->saveWc ().y = yRoot + (w->border ().top >> 1);449 * any movement here atomic */
445450 compiz::window::configure_buffers::ReleasablePtr lock (w->obtainLockOnConfigureRequests ());
446 ms->x = ms->y = 0;
447451
448 w->maximize (0);452 w->maximize (0);
449453
454 XWindowChanges xwc;
455 xwc.x = xRoot - (width / 2);
456 xwc.y = yRoot + w->border ().top / 2;
457
458 w->configureXWindow (CWX | CWY, &xwc);
459
450 ms->snapOffX = ms->snapBackX;460 ms->snapOffX = ms->snapBackX;
451461
452 return;462 return;
453463
=== modified file 'plugins/opengl/src/paint.cpp'
--- plugins/opengl/src/paint.cpp 2013-05-08 15:13:28 +0000
+++ plugins/opengl/src/paint.cpp 2013-06-29 07:09:28 +0000
@@ -426,7 +426,7 @@
426 gw = GLWindow::get (w);426 gw = GLWindow::get (w);
427427
428 /* Release any queued ConfigureWindow requests now */428 /* Release any queued ConfigureWindow requests now */
429 gw->priv->configureLock->release ();429 gw->priv->configureLock->release ();
430430
431 if (unredirected.find (w) != unredirected.end ())431 if (unredirected.find (w) != unredirected.end ())
432 continue;432 continue;
433433
=== modified file 'plugins/place/src/constrain-to-workarea/include/constrain-to-workarea.h'
--- plugins/place/src/constrain-to-workarea/include/constrain-to-workarea.h 2013-06-07 05:51:45 +0000
+++ plugins/place/src/constrain-to-workarea/include/constrain-to-workarea.h 2013-06-29 07:09:28 +0000
@@ -45,8 +45,7 @@
45CompPoint & constrainPositionToWorkArea (CompPoint &pos,45CompPoint & constrainPositionToWorkArea (CompPoint &pos,
46 const compiz::window::Geometry &serverGeometry,46 const compiz::window::Geometry &serverGeometry,
47 const CompWindowExtents &border,47 const CompWindowExtents &border,
48 const CompRect &workArea,48 const CompRect &workArea);
49 bool staticGravity);
5049
5150
52CompPoint getViewportRelativeCoordinates (const compiz::window::Geometry &geom,51CompPoint getViewportRelativeCoordinates (const compiz::window::Geometry &geom,
@@ -54,8 +53,7 @@
5453
55CompWindowExtents getWindowEdgePositions (const CompPoint &position,54CompWindowExtents getWindowEdgePositions (const CompPoint &position,
56 const compiz::window::Geometry &geom,55 const compiz::window::Geometry &geom,
57 const CompWindowExtents &border,56 const CompWindowExtents &border);
58 unsigned int gravity);
5957
60void clampHorizontalEdgePositionsToWorkArea (CompWindowExtents &edgePositions,58void clampHorizontalEdgePositionsToWorkArea (CompWindowExtents &edgePositions,
61 const CompRect &workArea);59 const CompRect &workArea);
@@ -64,8 +62,7 @@
6462
65void subtractBordersFromEdgePositions (CompWindowExtents &edgePositions,63void subtractBordersFromEdgePositions (CompWindowExtents &edgePositions,
66 const CompWindowExtents &border,64 const CompWindowExtents &border,
67 unsigned int legacyBorder,65 unsigned int legacyBorder);
68 unsigned int gravity);
6966
70bool onlySizeChanged (unsigned int mask);67bool onlySizeChanged (unsigned int mask);
71bool applyWidthChange (const CompWindowExtents &edgePositions,68bool applyWidthChange (const CompWindowExtents &edgePositions,
7269
=== modified file 'plugins/place/src/constrain-to-workarea/src/constrain-to-workarea.cpp'
--- plugins/place/src/constrain-to-workarea/src/constrain-to-workarea.cpp 2013-06-07 05:51:45 +0000
+++ plugins/place/src/constrain-to-workarea/src/constrain-to-workarea.cpp 2013-06-29 07:09:28 +0000
@@ -140,35 +140,21 @@
140140
141CompPoint &141CompPoint &
142cp::constrainPositionToWorkArea (CompPoint &pos,142cp::constrainPositionToWorkArea (CompPoint &pos,
143 const cw::Geometry &serverGeometry,143 const cw::Geometry &serverGeometry,
144 const CompWindowExtents &border,144 const CompWindowExtents &border,
145 const CompRect &workArea,145 const CompRect &workArea)
146 bool staticGravity)
147{146{
148 CompWindowExtents extents;147 CompWindowExtents extents;
149 int delta;148 int delta;
150149
151 CompWindowExtents effectiveBorders = border;150 extents.left = pos.x () - border.left;
152151 extents.top = pos.y () - border.top;
153 /* Ignore borders in the StaticGravity case for placement
154 * because the window intended to be placed as if it didn't
155 * have them */
156 if (staticGravity)
157 {
158 effectiveBorders.left = 0;
159 effectiveBorders.right = 0;
160 effectiveBorders.top = 0;
161 effectiveBorders.bottom = 0;
162 }
163
164 extents.left = pos.x () - effectiveBorders.left;
165 extents.top = pos.y () - effectiveBorders.top;
166 extents.right = extents.left + serverGeometry.widthIncBorders () +152 extents.right = extents.left + serverGeometry.widthIncBorders () +
167 (effectiveBorders.left +153 (border.left +
168 effectiveBorders.right);154 border.right);
169 extents.bottom = extents.top + serverGeometry.heightIncBorders () +155 extents.bottom = extents.top + serverGeometry.heightIncBorders () +
170 (effectiveBorders.top +156 (border.top +
171 effectiveBorders.bottom);157 border.bottom);
172158
173 delta = workArea.right () - extents.right;159 delta = workArea.right () - extents.right;
174 if (delta < 0)160 if (delta < 0)
@@ -186,8 +172,8 @@
186 if (delta > 0)172 if (delta > 0)
187 extents.top += delta;173 extents.top += delta;
188174
189 pos.setX (extents.left + effectiveBorders.left);175 pos.setX (extents.left + border.left);
190 pos.setY (extents.top + effectiveBorders.top);176 pos.setY (extents.top + border.top);
191177
192 return pos;178 return pos;
193}179}
@@ -213,23 +199,18 @@
213199
214CompWindowExtents cp::getWindowEdgePositions (const CompPoint &position,200CompWindowExtents cp::getWindowEdgePositions (const CompPoint &position,
215 const cw::Geometry &geom,201 const cw::Geometry &geom,
216 const CompWindowExtents &border,202 const CompWindowExtents &border)
217 unsigned int gravity)
218{203{
219 CompWindowExtents edgePositions;204 CompWindowExtents edgePositions;
220 CompWindowExtents effectiveBorder (border);205
221206 edgePositions.left = position.x () - border.left;
222 if (gravity & StaticGravity)
223 effectiveBorder = CompWindowExtents (0, 0, 0, 0);
224
225 edgePositions.left = position.x () - effectiveBorder.left;
226 edgePositions.right = edgePositions.left +207 edgePositions.right = edgePositions.left +
227 geom.widthIncBorders () + (effectiveBorder.left +208 geom.widthIncBorders () + (border.left +
228 effectiveBorder.right);209 border.right);
229 edgePositions.top = position.y () - effectiveBorder.top;210 edgePositions.top = position.y () - border.top;
230 edgePositions.bottom = edgePositions.top +211 edgePositions.bottom = edgePositions.top +
231 geom.heightIncBorders () + (effectiveBorder.top +212 geom.heightIncBorders () + (border.top +
232 effectiveBorder.bottom);213 border.bottom);
233214
234 return edgePositions;215 return edgePositions;
235}216}
@@ -285,19 +266,14 @@
285266
286void cp::subtractBordersFromEdgePositions (CompWindowExtents &edgePositions,267void cp::subtractBordersFromEdgePositions (CompWindowExtents &edgePositions,
287 const CompWindowExtents &border,268 const CompWindowExtents &border,
288 unsigned int legacyBorder,269 unsigned int legacyBorder)
289 unsigned int gravity)
290{270{
291 const unsigned int doubleBorder = 2 * legacyBorder;271 const unsigned int doubleBorder = 2 * legacyBorder;
292 CompWindowExtents effectiveBorder = border;272
293273 edgePositions.left += border.left;
294 if (gravity & StaticGravity)274 edgePositions.right -= border.right + doubleBorder;
295 effectiveBorder = CompWindowExtents (0, 0, 0, 0);275 edgePositions.top += border.top;
296276 edgePositions.bottom -= border.bottom + doubleBorder;
297 edgePositions.left += effectiveBorder.left;
298 edgePositions.right -= effectiveBorder.right + doubleBorder;
299 edgePositions.top += effectiveBorder.top;
300 edgePositions.bottom -= effectiveBorder.bottom + doubleBorder;
301}277}
302278
303bool cp::onlySizeChanged (unsigned int mask)279bool cp::onlySizeChanged (unsigned int mask)
304280
=== modified file 'plugins/place/src/constrain-to-workarea/tests/constrain-to-workarea/src/test-place-constrain-to-workarea.cpp'
--- plugins/place/src/constrain-to-workarea/tests/constrain-to-workarea/src/test-place-constrain-to-workarea.cpp 2013-06-07 05:51:45 +0000
+++ plugins/place/src/constrain-to-workarea/tests/constrain-to-workarea/src/test-place-constrain-to-workarea.cpp 2013-06-29 07:09:28 +0000
@@ -226,7 +226,7 @@
226 extents = WindowExtents (GetParam ());226 extents = WindowExtents (GetParam ());
227227
228 CompPoint pos = InitialPosition (GetParam ());228 CompPoint pos = InitialPosition (GetParam ());
229 pos = cp::constrainPositionToWorkArea (pos, g, extents, WArea, false);229 pos = cp::constrainPositionToWorkArea (pos, g, extents, WArea);
230230
231 const CompPoint expectedAfterExtentsAdjustment = ExpectedPosition +231 const CompPoint expectedAfterExtentsAdjustment = ExpectedPosition +
232 CompPoint (extents.left,232 CompPoint (extents.left,
@@ -235,19 +235,6 @@
235 EXPECT_EQ (expectedAfterExtentsAdjustment, pos);235 EXPECT_EQ (expectedAfterExtentsAdjustment, pos);
236}236}
237237
238TEST_P (PlaceConstrainPositionToWorkArea, PositionConstrainedStaticGravity)
239{
240 g = WindowGeometry (GetParam ());
241 extents = WindowExtents (GetParam ());
242
243 CompPoint pos = InitialPosition (GetParam ());
244 pos = cp::constrainPositionToWorkArea (pos, g, extents, WArea, true);
245
246 /* Do not adjust residual position for extents with windows
247 * that have a static gravity */
248 EXPECT_EQ (ExpectedPosition, pos);
249}
250
251namespace238namespace
252{239{
253cwe::Extents PossibleExtents[] =240cwe::Extents PossibleExtents[] =
@@ -297,7 +284,7 @@
297 CompPoint pos;284 CompPoint pos;
298};285};
299286
300TEST_F (PlaceGetEdgePositions, GetEdgePositionsNWGravity)287TEST_F (PlaceGetEdgePositions, GetEdgePositions)
301{288{
302 int left = geom.x () - border.left;289 int left = geom.x () - border.left;
303 int right = left + (geom.widthIncBorders ()) +290 int right = left + (geom.widthIncBorders ()) +
@@ -309,25 +296,7 @@
309 const cwe::Extents ExpectedExtents (left, right, top, bottom);296 const cwe::Extents ExpectedExtents (left, right, top, bottom);
310 cwe::Extents actualExtents (cp::getWindowEdgePositions (pos,297 cwe::Extents actualExtents (cp::getWindowEdgePositions (pos,
311 geom,298 geom,
312 border,299 border));
313 NorthWestGravity));
314
315 EXPECT_EQ (ExpectedExtents, actualExtents);
316}
317
318TEST_F (PlaceGetEdgePositions, GetEdgePositionsStaticGravity)
319{
320 /* Don't count borders in validation */
321 int left = geom.x ();
322 int right = left + (geom.widthIncBorders ());
323 int top = geom.y ();
324 int bottom = top + (geom.heightIncBorders ());
325
326 const cwe::Extents ExpectedExtents (left, right, top, bottom);
327 cwe::Extents actualExtents (cp::getWindowEdgePositions (pos,
328 geom,
329 border,
330 StaticGravity));
331300
332 EXPECT_EQ (ExpectedExtents, actualExtents);301 EXPECT_EQ (ExpectedExtents, actualExtents);
333}302}
@@ -527,29 +496,7 @@
527496
528 cp::subtractBordersFromEdgePositions (modifiedEdgePositions,497 cp::subtractBordersFromEdgePositions (modifiedEdgePositions,
529 borders,498 borders,
530 legacyBorder,499 legacyBorder);
531 NorthWestGravity);
532
533 EXPECT_EQ (expectedEdgePositions, modifiedEdgePositions);
534}
535
536TEST (PlaceSubtractBordersFromEdgePositions, StaticGravityDefinition)
537{
538 const CompWindowExtents borders (1, 2, 3, 4);
539 const CompWindowExtents edgePositions (100, 200, 100, 200);
540 const unsigned int legacyBorder = 1;
541
542 CompWindowExtents expectedEdgePositions (edgePositions.left,
543 edgePositions.right - (2 * legacyBorder),
544 edgePositions.top,
545 edgePositions.bottom - (2 * legacyBorder));
546
547 CompWindowExtents modifiedEdgePositions (edgePositions);
548
549 cp::subtractBordersFromEdgePositions (modifiedEdgePositions,
550 borders,
551 legacyBorder,
552 StaticGravity);
553500
554 EXPECT_EQ (expectedEdgePositions, modifiedEdgePositions);501 EXPECT_EQ (expectedEdgePositions, modifiedEdgePositions);
555}502}
556503
=== modified file 'plugins/place/src/place.cpp'
--- plugins/place/src/place.cpp 2013-06-07 05:51:45 +0000
+++ plugins/place/src/place.cpp 2013-06-29 07:09:28 +0000
@@ -362,8 +362,7 @@
362362
363 CompWindowExtents edgePositions = cp::getWindowEdgePositions (pos,363 CompWindowExtents edgePositions = cp::getWindowEdgePositions (pos,
364 geom,364 geom,
365 window->border (),365 window->border ());
366 window->sizeHints ().win_gravity);
367366
368 int output = screen->outputDeviceForGeometry (geom);367 int output = screen->outputDeviceForGeometry (geom);
369 CompRect workArea = screen->getWorkareaForOutput (output);368 CompRect workArea = screen->getWorkareaForOutput (output);
@@ -386,8 +385,7 @@
386 /* bring left/right/top/bottom to actual window coordinates */385 /* bring left/right/top/bottom to actual window coordinates */
387 cp::subtractBordersFromEdgePositions (edgePositions,386 cp::subtractBordersFromEdgePositions (edgePositions,
388 window->border (),387 window->border (),
389 geom.border (),388 geom.border ());
390 window->sizeHints ().win_gravity);
391389
392 /* always validate position if the application changed only its size,390 /* always validate position if the application changed only its size,
393 * as it might become partially offscreen because of that */391 * as it might become partially offscreen because of that */
@@ -436,7 +434,9 @@
436 if (!mask)434 if (!mask)
437 return;435 return;
438436
439 if (source == ClientTypePager)437 /* Clamp all windows initially on placement */
438 if (window->placed () &&
439 source == ClientTypePager)
440 return;440 return;
441441
442 if (window->state () & CompWindowStateFullscreenMask)442 if (window->state () & CompWindowStateFullscreenMask)
@@ -446,14 +446,16 @@
446 CompWindowTypeDesktopMask))446 CompWindowTypeDesktopMask))
447 return;447 return;
448448
449 /* do nothing if the window was already (at least partially) offscreen */449 /* do nothing if the window was already (at least partially) offscreen
450 if (window->serverX () < 0 ||450 * and already placed */
451 window->serverX () + window->serverWidth () > screen->width () ||451 bool onscreen =
452 window->serverY () < 0 ||452 CompRect (0,
453 window->serverY () + window->serverHeight () > screen->height ())453 0,
454 {454 screen->width (),
455 screen->height ()).contains (window->geometry ());
456
457 if (window->placed () && !onscreen)
455 return;458 return;
456 }
457459
458 if (hasUserDefinedPosition (false))460 if (hasUserDefinedPosition (false))
459 /* try to keep the window position intact for USPosition -461 /* try to keep the window position intact for USPosition -
@@ -1143,13 +1145,10 @@
1143PlaceWindow::constrainToWorkarea (const CompRect &workArea,1145PlaceWindow::constrainToWorkarea (const CompRect &workArea,
1144 CompPoint &pos)1146 CompPoint &pos)
1145{1147{
1146 bool staticGravity = window->sizeHints ().win_gravity & StaticGravity;
1147
1148 pos = cp::constrainPositionToWorkArea (pos,1148 pos = cp::constrainPositionToWorkArea (pos,
1149 window->serverGeometry (),1149 window->serverGeometry (),
1150 window->border (),1150 window->border (),
1151 workArea,1151 workArea);
1152 staticGravity);
11531152
1154}1153}
11551154
11561155
=== modified file 'src/event.cpp'
--- src/event.cpp 2013-03-19 10:00:10 +0000
+++ src/event.cpp 2013-06-29 07:09:28 +0000
@@ -1343,8 +1343,13 @@
1343 * that to wait until the map request */1343 * that to wait until the map request */
1344 if (wa.root == privateScreen.rootWindow())1344 if (wa.root == privateScreen.rootWindow())
1345 {1345 {
1346 PrivateWindow::createCompWindow (CompWindowToWindow (getTopWindow ()), CompWindowToWindow (getTopServerWindow ()), wa, event->xcreatewindow.window);1346 Window top = CompWindowToWindow (getTopWindow ());
1347 }1347 Window topServer = CompWindowToWindow (getTopServerWindow ());
1348 PrivateWindow::createCompWindow (top,
1349 topServer,
1350 wa,
1351 event->xcreatewindow.window);
1352 }
1348 else1353 else
1349 XSelectInput (privateScreen.dpy, event->xcreatewindow.window,1354 XSelectInput (privateScreen.dpy, event->xcreatewindow.window,
1350 FocusChangeMask);1355 FocusChangeMask);
13511356
=== modified file 'src/plugin.cpp'
--- src/plugin.cpp 2013-06-22 14:47:34 +0000
+++ src/plugin.cpp 2013-06-29 07:09:28 +0000
@@ -31,6 +31,8 @@
31#include <boost/scoped_array.hpp>31#include <boost/scoped_array.hpp>
32#include <boost/foreach.hpp>32#include <boost/foreach.hpp>
3333
34#include <boost/algorithm/string.hpp>
35
34#include <stdio.h>36#include <stdio.h>
35#include <stdlib.h>37#include <stdlib.h>
36#include <string.h>38#include <string.h>
@@ -424,8 +426,19 @@
424426
425 if (compiz_plugin_dir_override)427 if (compiz_plugin_dir_override)
426 {428 {
427 if (loaderLoadPlugin (p.get (), compiz_plugin_dir_override, name))429 std::vector <std::string> paths;
428 return p.release ();430 boost::split (paths,
431 compiz_plugin_dir_override,
432 boost::is_any_of (":"));
433
434 foreach (const std::string &path, paths)
435 {
436 if (path.empty ())
437 continue;
438
439 if (loaderLoadPlugin (p.get (), path.c_str (), name))
440 return p.release ();
441 }
429 }442 }
430443
431 if (char* home = getenv ("HOME"))444 if (char* home = getenv ("HOME"))
432445
=== modified file 'src/plugin/tests/test-plugin.cpp'
--- src/plugin/tests/test-plugin.cpp 2013-05-28 23:36:08 +0000
+++ src/plugin/tests/test-plugin.cpp 2013-06-29 07:09:28 +0000
@@ -182,6 +182,46 @@
182 CompPlugin::unload(cp);182 CompPlugin::unload(cp);
183}183}
184184
185TEST_F (PluginTest, load_plugin_from_multi_COMPIZ_PLUGIN_DIR_env_succeeds)
186{
187 std::string COMPIZ_PLUGIN_DIR_PART1 = "/path/to/plugin/dir";
188 std::string COMPIZ_PLUGIN_DIR_PART2 = "/dir/plugin/to/path";
189 std::string COMPIZ_PLUGIN_DIR_VALUE = COMPIZ_PLUGIN_DIR_PART1 + ":" +
190 COMPIZ_PLUGIN_DIR_PART2;
191 TmpEnv env ("COMPIZ_PLUGIN_DIR", COMPIZ_PLUGIN_DIR_VALUE.c_str ());
192
193 using namespace testing;
194
195 EXPECT_CALL(mockfs, LoadPlugin(_,
196 EndsWith(COMPIZ_PLUGIN_DIR_PART1),
197 StrEq("dummy"))).
198 WillOnce(Return(false));
199
200 EXPECT_CALL(mockfs, LoadPlugin(Ne((void*)0),
201 StrEq(COMPIZ_PLUGIN_DIR_PART2),
202 StrEq("dummy"))).
203 WillOnce(Return(true));
204
205 EXPECT_CALL(mockfs, LoadPlugin(Ne((void*)0),
206 EndsWith(HOME_PLUGINDIR), StrEq("dummy"))).
207 Times(AtMost(0));
208
209 EXPECT_CALL(mockfs, LoadPlugin(Ne((void*)0),
210 EndsWith(PLUGINDIR), StrEq("dummy"))).
211 Times(AtMost(0));
212
213 EXPECT_CALL(mockfs, LoadPlugin(Ne((void*)0),
214 Eq((void*)0), StrEq("dummy"))).
215 Times(AtMost(0));
216
217 EXPECT_CALL(mockfs, UnloadPlugin(_)).Times(1);
218
219 CompPlugin* cp = CompPlugin::load("dummy");
220 ASSERT_NE((void*)0, cp);
221
222 CompPlugin::unload(cp);
223}
224
185TEST_F (PluginTest, load_plugin_from_void_succeeds)225TEST_F (PluginTest, load_plugin_from_void_succeeds)
186{226{
187 using namespace testing;227 using namespace testing;
188228
=== modified file 'src/window.cpp'
--- src/window.cpp 2013-05-27 16:19:59 +0000
+++ src/window.cpp 2013-06-29 07:09:28 +0000
@@ -2884,17 +2884,21 @@
28842884
2885 int m = mask & ~saveMask;2885 int m = mask & ~saveMask;
28862886
2887 /* The saved window geometry is always saved in terms of the non-decorated
2888 * geometry as we may need to restore it with a different decoration size */
2887 if (m & CWX)2889 if (m & CWX)
2888 saveWc.x = serverGeometry.x ();2890 saveWc.x = serverGeometry.x () - window->border ().left;
28892891
2890 if (m & CWY)2892 if (m & CWY)
2891 saveWc.y = serverGeometry.y ();2893 saveWc.y = serverGeometry.y () - window->border ().top;
28922894
2893 if (m & CWWidth)2895 if (m & CWWidth)
2894 saveWc.width = serverGeometry.width ();2896 saveWc.width = serverGeometry.width () + (window->border ().left +
2897 window->border ().right);
28952898
2896 if (m & CWHeight)2899 if (m & CWHeight)
2897 saveWc.height = serverGeometry.height ();2900 saveWc.height = serverGeometry.height () + (window->border ().top +
2901 window->border ().bottom);
28982902
2899 if (m & CWBorderWidth)2903 if (m & CWBorderWidth)
2900 saveWc.border_width = serverGeometry.border ();2904 saveWc.border_width = serverGeometry.border ();
@@ -2909,44 +2913,18 @@
2909 int m = mask & saveMask;2913 int m = mask & saveMask;
29102914
2911 if (m & CWX)2915 if (m & CWX)
2912 xwc->x = saveWc.x;2916 xwc->x = saveWc.x + window->border ().left;
29132917
2914 if (m & CWY)2918 if (m & CWY)
2915 xwc->y = saveWc.y;2919 xwc->y = saveWc.y + window->border ().top;
29162920
2917 if (m & CWWidth)2921 if (m & CWWidth)
2918 {2922 xwc->width = saveWc.width - (window->border ().left +
2919 xwc->width = saveWc.width;2923 window->border ().right);
2920
2921 /* This is not perfect but it works OK for now. If the saved width is
2922 the same as the current width then make it a little be smaller so
2923 the user can see that it changed and it also makes sure that
2924 windowResizeNotify is called and plugins are notified.
2925 TODO: Eliminate these arbitrary magic numbers here */
2926 if (xwc->width == (int) serverGeometry.width ())
2927 {
2928 xwc->width -= 10;
2929
2930 if (m & CWX)
2931 xwc->x += 5;
2932 }
2933 }
29342924
2935 if (m & CWHeight)2925 if (m & CWHeight)
2936 {2926 xwc->height = saveWc.height - (window->border ().top +
2937 xwc->height = saveWc.height;2927 window->border ().bottom);
2938
2939 /* As above, if the saved height is the same as the current height
2940 then make it a little be smaller.
2941 TODO: As above, find a better solution without magic numbers here */
2942 if (xwc->height == (int) serverGeometry.height ())
2943 {
2944 xwc->height -= 10;
2945
2946 if (m & CWY)
2947 xwc->y += 5;
2948 }
2949 }
29502928
2951 if (m & CWBorderWidth)2929 if (m & CWBorderWidth)
2952 xwc->border_width = saveWc.border_width;2930 xwc->border_width = saveWc.border_width;
@@ -5493,8 +5471,8 @@
5493 unsigned int xwcm;5471 unsigned int xwcm;
54945472
5495 /* adjust for gravity, but only for frame size */5473 /* adjust for gravity, but only for frame size */
5496 xwc.x = priv->serverGeometry.x ();5474 xwc.x = priv->serverGeometry.x () - priv->border.left;
5497 xwc.y = priv->serverGeometry.y ();5475 xwc.y = priv->serverGeometry.y () - priv->border.top;
5498 xwc.width = 0;5476 xwc.width = 0;
5499 xwc.height = 0;5477 xwc.height = 0;
55005478
@@ -5503,6 +5481,9 @@
5503 xwc.width = priv->serverGeometry.width ();5481 xwc.width = priv->serverGeometry.width ();
5504 xwc.height = priv->serverGeometry.height ();5482 xwc.height = priv->serverGeometry.height ();
55055483
5484 /* Validate size */
5485 xwcm |= CWWidth | CWHeight;
5486
5506 window->validateResizeRequest (xwcm, &xwc, ClientTypeApplication);5487 window->validateResizeRequest (xwcm, &xwc, ClientTypeApplication);
55075488
5508 CompPoint pos (xwc.x, xwc.y);5489 CompPoint pos (xwc.x, xwc.y);
@@ -6605,24 +6586,39 @@
6605 priv->border.top != b->top ||6586 priv->border.top != b->top ||
6606 priv->border.bottom != b->bottom)6587 priv->border.bottom != b->bottom)
6607 {6588 {
6589 CompPoint movement =
6590 compiz::window::extents::shift (*b,
6591 priv->sizeHints.win_gravity) -
6592 compiz::window::extents::shift (priv->border,
6593 priv->sizeHints.win_gravity);
6594 CompSize sizeDelta = CompSize (-((b->left + b->right) -
6595 (priv->border.left + priv->border.right)),
6596 -((b->top + b->bottom) -
6597 (priv->border.top + priv->border.bottom)));
6598
6608 priv->serverInput = *i;6599 priv->serverInput = *i;
6609 priv->border = *b;6600 priv->border = *b;
66106601
6602 /* Offset client for any new decoration size */
6603 XWindowChanges xwc;
6604
6605 xwc.x = movement.x () + priv->serverGeometry.x ();
6606 xwc.y = movement.y () + priv->serverGeometry.y ();
6607 xwc.width = sizeDelta.width () + priv->serverGeometry.width ();
6608 xwc.height = sizeDelta.height () + priv->serverGeometry.height ();
6609
6610 configureXWindow (CWX | CWY | CWWidth | CWHeight, &xwc);
6611
6612 windowNotify (CompWindowNotifyFrameUpdate);
6611 recalcActions ();6613 recalcActions ();
66126614
6613 bool sizeUpdated = false;
6614
6615 sizeUpdated |= priv->updateSize ();
6616 sizeUpdated |= priv->updateFrameWindow ();
6617
6618 /* Always send a moveNotify6615 /* Always send a moveNotify
6619 * whenever the frame extents update6616 * whenever the frame extents update
6620 * so that plugins can re-position appropriately */6617 * so that plugins can re-position appropriately */
6621 moveNotify (0, 0, true);6618 moveNotify (0, 0, true);
66226619
6623 /* Once we have updated everything, re-set lastServerInput */6620 /* Once we have updated everything, re-set lastServerInput */
6624 if (sizeUpdated)6621 priv->lastServerInput = priv->serverInput;
6625 priv->lastServerInput = priv->serverInput;
6626 }6622 }
66276623
6628 /* Use b for _NET_WM_FRAME_EXTENTS here because6624 /* Use b for _NET_WM_FRAME_EXTENTS here because
@@ -6746,11 +6742,28 @@
6746 /* Gravity here is assumed to be SouthEast, clients can update6742 /* Gravity here is assumed to be SouthEast, clients can update
6747 * that if need be */6743 * that if need be */
67486744
6745 serverFrameGeometry.set (serverInput.left - border.left,
6746 serverInput.top - border.top,
6747 wa.width + (serverInput.left +
6748 serverInput.right),
6749 wa.height + (serverInput.top +
6750 serverInput.bottom),
6751 0);
6752
6749 /* Awaiting a new frame to be given to us */6753 /* Awaiting a new frame to be given to us */
6750 frame = None;6754 frame = None;
6751 serverFrame = XCreateWindow (dpy, screen->root (), 0, 0,6755 serverFrame = XCreateWindow (dpy,
6752 wa.width, wa.height, 0, wa.depth,6756 screen->root (),
6753 InputOutput, visual, mask, &attr);6757 serverFrameGeometry.x (),
6758 serverFrameGeometry.y (),
6759 serverFrameGeometry.width (),
6760 serverFrameGeometry.height (),
6761 serverFrameGeometry.border (),
6762 wa.depth,
6763 InputOutput,
6764 visual,
6765 mask,
6766 &attr);
67546767
6755 /* Do not get any events from here on */6768 /* Do not get any events from here on */
6756 XSelectInput (dpy, screen->root (), NoEventMask);6769 XSelectInput (dpy, screen->root (), NoEventMask);
@@ -6758,11 +6771,16 @@
6758 /* If we have some frame extents, we should apply them here and6771 /* If we have some frame extents, we should apply them here and
6759 * set lastFrameExtents */6772 * set lastFrameExtents */
6760 wrapper = XCreateWindow (dpy, serverFrame,6773 wrapper = XCreateWindow (dpy, serverFrame,
6761 serverInput.left, serverInput.top,6774 serverInput.left,
6762 wa.width - (serverInput.left + serverInput.right),6775 serverInput.top,
6763 wa.height - (serverInput.top + serverInput.bottom),6776 wa.width,
6764 0, wa.depth,6777 wa.height,
6765 InputOutput, visual, mask, &attr);6778 0,
6779 wa.depth,
6780 InputOutput,
6781 visual,
6782 mask,
6783 &attr);
67666784
6767 lastServerInput = serverInput;6785 lastServerInput = serverInput;
6768 xwc.stack_mode = Above;6786 xwc.stack_mode = Above;
@@ -6836,11 +6854,6 @@
6836 attr.event_mask = SubstructureRedirectMask | SubstructureNotifyMask |6854 attr.event_mask = SubstructureRedirectMask | SubstructureNotifyMask |
6837 EnterWindowMask | LeaveWindowMask;6855 EnterWindowMask | LeaveWindowMask;
68386856
6839 serverFrameGeometry = serverGeometry;
6840
6841 XMoveResizeWindow (dpy, serverFrame, serverFrameGeometry.x (), serverFrameGeometry.y (),
6842 serverFrameGeometry.width (), serverFrameGeometry.height ());
6843
6844 XChangeWindowAttributes (dpy, serverFrame, CWEventMask, &attr);6857 XChangeWindowAttributes (dpy, serverFrame, CWEventMask, &attr);
6845 XChangeWindowAttributes (dpy, wrapper, CWEventMask, &attr);6858 XChangeWindowAttributes (dpy, wrapper, CWEventMask, &attr);
68466859
68476860
=== modified file 'src/window/extents/src/windowextents.cpp'
--- src/window/extents/src/windowextents.cpp 2013-06-07 05:51:45 +0000
+++ src/window/extents/src/windowextents.cpp 2013-06-29 07:09:28 +0000
@@ -35,6 +35,11 @@
35 CompPoint rv = CompPoint ();35 CompPoint rv = CompPoint ();
3636
37 switch (gravity) {37 switch (gravity) {
38 /* We treat StaticGravity like NorthWestGravity here
39 * as when decorating / undecorating the window we
40 * really do need to move it in order to handle
41 * any cases where it goes offscreen */
42 case StaticGravity:
38 case NorthGravity:43 case NorthGravity:
39 case NorthWestGravity:44 case NorthWestGravity:
40 case NorthEastGravity:45 case NorthEastGravity:
@@ -50,6 +55,11 @@
50 }55 }
5156
52 switch (gravity) {57 switch (gravity) {
58 /* We treat StaticGravity like NorthWestGravity here
59 * as when decorating / undecorating the window we
60 * really do need to move it in order to handle
61 * any cases where it goes offscreen */
62 case StaticGravity:
53 case WestGravity:63 case WestGravity:
54 case NorthWestGravity:64 case NorthWestGravity:
55 case SouthWestGravity:65 case SouthWestGravity:
5666
=== added file 'tests/manual/README.txt'
--- tests/manual/README.txt 1970-01-01 00:00:00 +0000
+++ tests/manual/README.txt 2013-06-29 07:09:28 +0000
@@ -0,0 +1,9 @@
1Compiz Manual Tests
2===================
3
4Avoid writing manual tests if you can. Acceptance tests that can be run
5on an automatic basis are always preferred.
6
7If getting some part of the code would be too difficult or invasive, then
8write a manual test in here so that we can remind ourselves to deploy test
9frameworks for the code in quesiton.
010
=== added file 'tests/manual/plugins/decor.txt'
--- tests/manual/plugins/decor.txt 1970-01-01 00:00:00 +0000
+++ tests/manual/plugins/decor.txt 2013-06-29 07:09:28 +0000
@@ -0,0 +1,40 @@
1COMPIZ DECOR PLUGIN
2===================
3Sam Spilsbury <smspillaz@gmail.com>
4
5Static Gravity Handling - no decorations
6----------------------------------------
7Setup:
8# Install guake
9
10Actions:
11# Start and launch guake
12
13Expected Result:
14 Guake should sit flush with the panels and work area
15
16Static Gravity Handling - decorations
17-------------------------------------
18Setup:
19# Install friends-app
20
21Actions:
22# Start and launch friends-app
23
24Expected Result:
25 The QML window should have its decorations visible and
26 be contained in the top left hand corner of the work area
27
28_NET_REQUEST_FRAME_EXTENTS handling
29-----------------------------------
30Setup:
31# Install any sun-awt application - examples:
32 1. netbeans
33 2. ecplise
34
35Actions:
36# Run the application
37
38Expected Result:
39 The application should not have its contents offset
40 by its decoration size
041
=== 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-06-22 12:27:36 +0000
+++ tests/system/xorg-gtest/tests/compiz_xorg_gtest_configure_window.cpp 2013-06-29 07:09:28 +0000
@@ -44,6 +44,11 @@
44using ::testing::MatchResultListener;44using ::testing::MatchResultListener;
45using ::testing::MakeMatcher;45using ::testing::MakeMatcher;
46using ::testing::Matcher;46using ::testing::Matcher;
47using ::testing::_;
48
49using ::compiz::testing::HasGeometry;
50using ::compiz::testing::RelativeWindowGeometry;
51using ::compiz::testing::AbsoluteWindowGeometry;
4752
48namespace ct = compiz::testing;53namespace ct = compiz::testing;
4954
@@ -191,7 +196,6 @@
191 void SendConfigureLockRequest (Window w, bool lockRequests);196 void SendConfigureLockRequest (Window w, bool lockRequests);
192 bool VerifyConfigureResponse (Window w, int x, int y, int width, int height);197 bool VerifyConfigureResponse (Window w, int x, int y, int width, int height);
193 bool VerifySetFrameExtentsResponse (Window w, int left, int right, int top, int bottom);198 bool VerifySetFrameExtentsResponse (Window w, int left, int right, int top, int bottom);
194 bool VerifyWindowSize (Window w, int x, int y, int width, int height);
195199
196 /* Helper functions for the Create*WindowOverrideRedirect* tests */200 /* Helper functions for the Create*WindowOverrideRedirect* tests */
197 Window GrabAndCreateWindowWithAttrs (::Display *dpy,201 Window GrabAndCreateWindowWithAttrs (::Display *dpy,
@@ -204,7 +208,7 @@
204 protected:208 protected:
205209
206 ReparentedWindow CreateWindow (::Display *);210 ReparentedWindow CreateWindow (::Display *);
207 int GetEventMask ();211 int GetEventMask () const;
208212
209 private:213 private:
210214
@@ -212,7 +216,7 @@
212};216};
213217
214int218int
215CompizXorgSystemConfigureWindowTest::GetEventMask ()219CompizXorgSystemConfigureWindowTest::GetEventMask () const
216{220{
217 return ct::AutostartCompizXorgSystemTestWithTestHelper::GetEventMask () |221 return ct::AutostartCompizXorgSystemTestWithTestHelper::GetEventMask () |
218 SubstructureNotifyMask;222 SubstructureNotifyMask;
@@ -336,28 +340,6 @@
336 return false;340 return false;
337}341}
338342
339bool
340CompizXorgSystemConfigureWindowTest::VerifyWindowSize (Window w,
341 int x,
342 int y,
343 int width,
344 int height)
345{
346 ::Display *dpy = Display ();
347
348 int xRet, yRet;
349 unsigned int widthRet, heightRet;
350 if (!QueryGeometry (dpy, w, xRet, yRet, widthRet, heightRet))
351 return false;
352
353 EXPECT_EQ (x, xRet);
354 EXPECT_EQ (y, yRet);
355 EXPECT_EQ (width, widthRet);
356 EXPECT_EQ (height, heightRet);
357
358 return true;
359}
360
361ReparentedWindow343ReparentedWindow
362CompizXorgSystemConfigureWindowTest::CreateWindow (::Display *dpy)344CompizXorgSystemConfigureWindowTest::CreateWindow (::Display *dpy)
363{345{
@@ -385,7 +367,13 @@
385 ASSERT_TRUE (VerifyConfigureResponse (w.client, x, y, width, height));367 ASSERT_TRUE (VerifyConfigureResponse (w.client, x, y, width, height));
386368
387 /* Query the window size again */369 /* Query the window size again */
388 ASSERT_TRUE (VerifyWindowSize (w.frame, x, y, width, height));370 ASSERT_THAT (w.frame, HasGeometry (dpy,
371 RelativeWindowGeometry,
372 x,
373 y,
374 width,
375 height,
376 _));
389377
390}378}
391379
@@ -410,7 +398,13 @@
410 ASSERT_TRUE (VerifySetFrameExtentsResponse (w.client, left, right, top, bottom));398 ASSERT_TRUE (VerifySetFrameExtentsResponse (w.client, left, right, top, bottom));
411399
412 /* Client geometry is always unchanged */400 /* Client geometry is always unchanged */
413 ASSERT_TRUE (VerifyWindowSize (w.client, x, y, width, height));401 ASSERT_THAT (w.client, HasGeometry (dpy,
402 RelativeWindowGeometry,
403 x,
404 y,
405 width,
406 height,
407 _));
414408
415 /* Frame geometry is frame geometry offset by extents */409 /* Frame geometry is frame geometry offset by extents */
416 x -= left;410 x -= left;
@@ -418,7 +412,13 @@
418 width += left + right;412 width += left + right;
419 height += top + bottom;413 height += top + bottom;
420414
421 ASSERT_TRUE (VerifyWindowSize (w.frame, x, y, width, height));415 ASSERT_THAT (w.frame, HasGeometry (dpy,
416 RelativeWindowGeometry,
417 x,
418 y,
419 width,
420 height,
421 _));
422}422}
423423
424TEST_F (CompizXorgSystemConfigureWindowTest, MoveFrameLocked)424TEST_F (CompizXorgSystemConfigureWindowTest, MoveFrameLocked)
@@ -448,11 +448,13 @@
448 ASSERT_TRUE (VerifyConfigureResponse (w.client, x, y, width, height));448 ASSERT_TRUE (VerifyConfigureResponse (w.client, x, y, width, height));
449449
450 /* Query the window size again - it should be the same */450 /* Query the window size again - it should be the same */
451 ASSERT_TRUE (VerifyWindowSize (w.frame,451 ASSERT_THAT (w.frame, HasGeometry (dpy,
452 currentX,452 RelativeWindowGeometry,
453 currentY,453 currentX,
454 currentWidth,454 currentY,
455 currentHeight));455 currentWidth,
456 currentHeight,
457 _));
456458
457459
458 SendConfigureLockRequest (w.client, false);460 SendConfigureLockRequest (w.client, false);
@@ -510,11 +512,13 @@
510 SendConfigureLockRequest (w.client, false);512 SendConfigureLockRequest (w.client, false);
511513
512 /* Query the window size again - it should be the same */514 /* Query the window size again - it should be the same */
513 ASSERT_TRUE (VerifyWindowSize (w.frame,515 ASSERT_THAT (w.frame, HasGeometry (dpy,
514 currentX,516 RelativeWindowGeometry,
515 currentY,517 currentX,
516 width,518 currentY,
517 height));519 width,
520 height,
521 _));
518}522}
519523
520TEST_F (CompizXorgSystemConfigureWindowTest, SetFrameExtentsLocked)524TEST_F (CompizXorgSystemConfigureWindowTest, SetFrameExtentsLocked)
@@ -562,11 +566,13 @@
562 SendConfigureLockRequest (w.client, false);566 SendConfigureLockRequest (w.client, false);
563567
564 /* Query the window size again - it should be the same */568 /* Query the window size again - it should be the same */
565 ASSERT_TRUE (VerifyWindowSize (w.frame,569 ASSERT_THAT (w.frame, HasGeometry (dpy,
566 currentX - left,570 RelativeWindowGeometry,
567 currentY - top,571 currentX - left,
568 currentWidth + (left + right),572 currentY - top,
569 currentHeight + (top + bottom)));573 currentWidth + (left + right),
574 currentHeight + (top + bottom),
575 _));
570}576}
571577
572/* Check that changing the frame extents by one on each side578/* Check that changing the frame extents by one on each side
@@ -598,11 +604,13 @@
598 /* Wrapper geometry is extents.xy, size.wh */604 /* Wrapper geometry is extents.xy, size.wh */
599 Window root;605 Window root;
600 Window wrapper = ct::GetImmediateParent (dpy, w.client, root);606 Window wrapper = ct::GetImmediateParent (dpy, w.client, root);
601 ASSERT_TRUE (VerifyWindowSize (wrapper,607 ASSERT_THAT (wrapper, HasGeometry (dpy,
602 left,608 RelativeWindowGeometry,
603 top,609 left,
604 currentWidth,610 top,
605 currentHeight));611 currentWidth,
612 currentHeight,
613 _));
606}614}
607615
608TEST_F (CompizXorgSystemConfigureWindowTest, SetFrameExtentsUnmapped)616TEST_F (CompizXorgSystemConfigureWindowTest, SetFrameExtentsUnmapped)
@@ -632,11 +640,13 @@
632 SendSetFrameExtentsRequest (client, left, right, top, bottom);640 SendSetFrameExtentsRequest (client, left, right, top, bottom);
633 ASSERT_TRUE (VerifySetFrameExtentsResponse (client, left, right, top, bottom));641 ASSERT_TRUE (VerifySetFrameExtentsResponse (client, left, right, top, bottom));
634642
635 ASSERT_TRUE (VerifyWindowSize (client,643 ASSERT_THAT (client, HasGeometry (dpy,
636 currentX,644 RelativeWindowGeometry,
637 currentY,645 currentX,
638 currentWidth,646 currentY,
639 currentHeight));647 currentWidth,
648 currentHeight,
649 _));
640}650}
641651
642TEST_F (CompizXorgSystemConfigureWindowTest, SetFrameExtentsCorrectMapBehaviour)652TEST_F (CompizXorgSystemConfigureWindowTest, SetFrameExtentsCorrectMapBehaviour)
@@ -670,20 +680,24 @@
670680
671 /* Check the geometry of the frame */681 /* Check the geometry of the frame */
672 Window frame = GetTopParent (dpy, client);682 Window frame = GetTopParent (dpy, client);
673 ASSERT_TRUE (VerifyWindowSize (frame,683 ASSERT_THAT (frame, HasGeometry (dpy,
674 currentX,684 RelativeWindowGeometry,
675 currentY,685 currentX - left,
676 currentWidth + (left + right),686 currentY - top,
677 currentHeight + (top + bottom)));687 currentWidth + (left + right),
688 currentHeight + (top + bottom),
689 _));
678690
679 /* Wrapper geometry is extents.xy, size.wh */691 /* Wrapper geometry is extents.xy, size.wh */
680 Window root;692 Window root;
681 Window wrapper = ct::GetImmediateParent (dpy, client, root);693 Window wrapper = ct::GetImmediateParent (dpy, client, root);
682 ASSERT_TRUE (VerifyWindowSize (wrapper,694 ASSERT_THAT (wrapper, HasGeometry (dpy,
683 left,695 RelativeWindowGeometry,
684 top,696 left,
685 currentWidth,697 top,
686 currentHeight));698 currentWidth,
699 currentHeight,
700 _));
687}701}
688702
689TEST_F (CompizXorgSystemConfigureWindowTest, SetFrameExtentsConsistentBehaviourAfterMap)703TEST_F (CompizXorgSystemConfigureWindowTest, SetFrameExtentsConsistentBehaviourAfterMap)
@@ -725,20 +739,24 @@
725739
726 /* Check the geometry of the frame */740 /* Check the geometry of the frame */
727 Window frame = GetTopParent (dpy, client);741 Window frame = GetTopParent (dpy, client);
728 ASSERT_TRUE (VerifyWindowSize (frame,742 ASSERT_THAT (frame, HasGeometry (dpy,
729 currentX,743 RelativeWindowGeometry,
730 currentY,744 currentX - left,
731 currentWidth + (left + right),745 currentY - top,
732 currentHeight + (top + bottom)));746 currentWidth + (left + right),
747 currentHeight + (top + bottom),
748 _));
733749
734 /* Wrapper geometry is extents.xy, size.wh */750 /* Wrapper geometry is extents.xy, size.wh */
735 Window root;751 Window root;
736 Window wrapper = ct::GetImmediateParent (dpy, client, root);752 Window wrapper = ct::GetImmediateParent (dpy, client, root);
737 ASSERT_TRUE (VerifyWindowSize (wrapper,753 ASSERT_THAT (wrapper, HasGeometry (dpy,
738 left,754 RelativeWindowGeometry,
739 top,755 left,
740 currentWidth,756 top,
741 currentHeight));757 currentWidth,
758 currentHeight,
759 _));
742}760}
743761
744762
745763
=== modified file 'tests/xorg-gtest/CMakeLists.txt'
--- tests/xorg-gtest/CMakeLists.txt 2013-06-10 08:43:28 +0000
+++ tests/xorg-gtest/CMakeLists.txt 2013-06-29 07:09:28 +0000
@@ -4,7 +4,8 @@
4set (COMPIZ_XORG_GTEST_COMMUNICATOR_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/communicator CACHE PATH "" FORCE)4set (COMPIZ_XORG_GTEST_COMMUNICATOR_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/communicator CACHE PATH "" FORCE)
5set (COMPIZ_XORG_GTEST_COMMUNICATOR_LIBRARY_DIRS ${CMAKE_CURRENT_BINARY_DIR}/communicator CACHE PATH "" FORCE)5set (COMPIZ_XORG_GTEST_COMMUNICATOR_LIBRARY_DIRS ${CMAKE_CURRENT_BINARY_DIR}/communicator CACHE PATH "" FORCE)
6set (COMPIZ_XORG_GTEST_COMMUNICATOR_LIBRARY compiz_xorg_gtest_communicator CACHE STRING "" FORCE)6set (COMPIZ_XORG_GTEST_COMMUNICATOR_LIBRARY compiz_xorg_gtest_communicator CACHE STRING "" FORCE)
7set (COMPIZ_OVERRIDE_PLUGIN_PATH ${CMAKE_CURRENT_BINARY_DIR}/plugins/testhelper)7set (COMPIZ_TEST_ONLY_PLUGIN_PATH ${CMAKE_CURRENT_BINARY_DIR}/plugins/)
8set (COMPIZ_REAL_PLUGIN_PATH ${CMAKE_BINARY_DIR}/plugins/)
89
9configure_file (${CMAKE_CURRENT_SOURCE_DIR}/src/compiz-xorg-gtest-config.h.in10configure_file (${CMAKE_CURRENT_SOURCE_DIR}/src/compiz-xorg-gtest-config.h.in
10 ${CMAKE_CURRENT_BINARY_DIR}/src/compiz-xorg-gtest-config.h11 ${CMAKE_CURRENT_BINARY_DIR}/src/compiz-xorg-gtest-config.h
1112
=== modified file 'tests/xorg-gtest/include/compiz-xorg-gtest.h'
--- tests/xorg-gtest/include/compiz-xorg-gtest.h 2013-06-22 12:27:36 +0000
+++ tests/xorg-gtest/include/compiz-xorg-gtest.h 2013-06-29 07:09:28 +0000
@@ -30,6 +30,7 @@
3030
31using ::testing::MatcherInterface;31using ::testing::MatcherInterface;
32using ::testing::MatchResultListener;32using ::testing::MatchResultListener;
33using ::testing::Matcher;
3334
34namespace compiz35namespace compiz
35{36{
@@ -143,6 +144,62 @@
143 const XEventMatcher &matcher,144 const XEventMatcher &matcher,
144 int timeout = 0);145 int timeout = 0);
145146
147 void RelativeWindowGeometry (Display *dpy,
148 Window w,
149 int &x,
150 int &y,
151 unsigned int &width,
152 unsigned int &height,
153 unsigned int &border);
154
155 void AbsoluteWindowGeometry (::Display *display,
156 Window window,
157 int &x,
158 int &y,
159 unsigned int &width,
160 unsigned int &height,
161 unsigned int &border);
162
163 typedef void (*RetrievalFunc) (Display *dpy,
164 Window window,
165 int &x,
166 int &y,
167 unsigned int &width,
168 unsigned int &height,
169 unsigned int &border);
170
171 class WindowGeometryMatcher :
172 public MatcherInterface <Window>
173 {
174 public:
175
176 WindowGeometryMatcher (Display *dpy,
177 RetrievalFunc func,
178 const Matcher <int> &x,
179 const Matcher <int> &y,
180 const Matcher <unsigned int> &width,
181 const Matcher <unsigned int> &height,
182 const Matcher <unsigned int> &border);
183
184 bool MatchAndExplain (Window x, MatchResultListener *listener) const;
185 void DescribeTo (std::ostream *os) const;
186
187 private:
188
189 class Private;
190
191 std::auto_ptr <Private> priv;
192 };
193
194 Matcher <Window>
195 HasGeometry (Display *dpy,
196 RetrievalFunc func,
197 const Matcher <int> &x,
198 const Matcher <int> &y,
199 const Matcher <unsigned int> &width,
200 const Matcher <unsigned int> &height,
201 const Matcher <unsigned int> &border);
202
146 class PrivateCompizProcess;203 class PrivateCompizProcess;
147 class CompizProcess204 class CompizProcess
148 {205 {
@@ -154,7 +211,26 @@
154 ExpectStartupFailure = (1 << 2)211 ExpectStartupFailure = (1 << 2)
155 } StartupFlags;212 } StartupFlags;
156213
157 typedef std::vector <std::string> PluginList;214 typedef enum _PluginType
215 {
216 Real = 0,
217 TestOnly = 1
218 } PluginType;
219
220 struct Plugin
221 {
222 Plugin (const char *name,
223 PluginType type) :
224 name (name),
225 type (type)
226 {
227 }
228
229 std::string name;
230 PluginType type;
231 };
232
233 typedef std::vector <Plugin> PluginList;
158234
159 CompizProcess (Display *dpy,235 CompizProcess (Display *dpy,
160 StartupFlags,236 StartupFlags,
@@ -196,7 +272,7 @@
196 AutostartCompizXorgSystemTest ();272 AutostartCompizXorgSystemTest ();
197273
198 virtual CompizProcess::StartupFlags GetStartupFlags ();274 virtual CompizProcess::StartupFlags GetStartupFlags ();
199 virtual int GetEventMask ();275 virtual int GetEventMask () const;
200 virtual CompizProcess::PluginList GetPluginList ();276 virtual CompizProcess::PluginList GetPluginList ();
201 virtual void SetUp ();277 virtual void SetUp ();
202278
@@ -222,7 +298,7 @@
222 std::vector <long> WaitForWindowCreation (Window w);298 std::vector <long> WaitForWindowCreation (Window w);
223 bool IsOverrideRedirect (std::vector <long> &data);299 bool IsOverrideRedirect (std::vector <long> &data);
224300
225 virtual int GetEventMask ();301 virtual int GetEventMask () const;
226302
227 private:303 private:
228304
229305
=== modified file 'tests/xorg-gtest/plugins/testhelper/src/testhelper.cpp'
--- tests/xorg-gtest/plugins/testhelper/src/testhelper.cpp 2013-05-09 13:43:07 +0000
+++ tests/xorg-gtest/plugins/testhelper/src/testhelper.cpp 2013-06-29 07:09:28 +0000
@@ -141,14 +141,11 @@
141void141void
142TestHelperWindow::setFrameExtentsAndReport (long *data)142TestHelperWindow::setFrameExtentsAndReport (long *data)
143{143{
144 CompWindowExtents input;144 /* Only change the frame input and not the border */
145145 CompWindowExtents input (data[0], data[1], data[2], data[3]);
146 input.left = data[0];146 CompWindowExtents border (0, 0, 0, 0);
147 input.right = data[1];147
148 input.top = data[2];148 window->setWindowFrameExtents (&border, &input);
149 input.bottom = data[3];
150
151 window->setWindowFrameExtents (&input, &input);
152149
153 std::vector <long> response;150 std::vector <long> response;
154151
155152
=== modified file 'tests/xorg-gtest/src/compiz-xorg-gtest-config.h.in'
--- tests/xorg-gtest/src/compiz-xorg-gtest-config.h.in 2013-02-14 05:57:39 +0000
+++ tests/xorg-gtest/src/compiz-xorg-gtest-config.h.in 2013-06-29 07:09:28 +0000
@@ -27,7 +27,8 @@
27{27{
28 const std::string compizLDLibraryPath ("@COMPIZ_LD_LIBRARY_PATH@");28 const std::string compizLDLibraryPath ("@COMPIZ_LD_LIBRARY_PATH@");
29 const std::string compizBinaryPath ("@COMPIZ_BINARY@");29 const std::string compizBinaryPath ("@COMPIZ_BINARY@");
30 const std::string compizOverridePluginPath ("@COMPIZ_OVERRIDE_PLUGIN_PATH@");30 const std::string compizTestOnlyPluginPath ("@COMPIZ_TEST_ONLY_PLUGIN_PATH@");
31 const std::string compizRealPluginPath ("@COMPIZ_REAL_PLUGIN_PATH@");
31}32}
3233
33#endif34#endif
3435
=== modified file 'tests/xorg-gtest/src/compiz-xorg-gtest.cpp'
--- tests/xorg-gtest/src/compiz-xorg-gtest.cpp 2013-06-22 12:27:36 +0000
+++ tests/xorg-gtest/src/compiz-xorg-gtest.cpp 2013-06-29 07:09:28 +0000
@@ -38,8 +38,10 @@
3838
39#include "compiz-xorg-gtest-config.h"39#include "compiz-xorg-gtest-config.h"
4040
41using ::testing::MakeMatcher;
41using ::testing::MatchResultListener;42using ::testing::MatchResultListener;
42using ::testing::MatcherInterface;43using ::testing::MatcherInterface;
44using ::testing::Matcher;
4345
44namespace ct = compiz::testing;46namespace ct = compiz::testing;
45namespace47namespace
@@ -512,6 +514,161 @@
512{514{
513}515}
514516
517void ct::RelativeWindowGeometry (Display *dpy,
518 Window w,
519 int &x,
520 int &y,
521 unsigned int &width,
522 unsigned int &height,
523 unsigned int &border)
524{
525 Window root;
526 unsigned int depth;
527
528 if (!XGetGeometry (dpy, w, &root, &x, &y, &width, &height, &border, &depth))
529 throw std::logic_error ("XGetGeometry failed");
530}
531
532void ct::AbsoluteWindowGeometry (Display *display,
533 Window window,
534 int &x,
535 int &y,
536 unsigned int &width,
537 unsigned int &height,
538 unsigned int &border)
539{
540 Window root;
541 Window child;
542 unsigned int depth;
543
544 if (!XGetGeometry (display, window, &root,
545 &x, &y, &width, &height,
546 &border, &depth))
547 throw std::logic_error ("XGetGeometry failed");
548
549 if (!XTranslateCoordinates (display, window, root, x, y,
550 &x, &y, &child))
551 throw std::logic_error ("XTranslateCoordinates failed");
552}
553
554class ct::WindowGeometryMatcher::Private
555{
556 public:
557
558 Private (Display *dpy,
559 ct::RetrievalFunc func,
560 const Matcher <int> &x,
561 const Matcher <int> &y,
562 const Matcher <unsigned int> &width,
563 const Matcher <unsigned int> &height,
564 const Matcher <unsigned int> &border);
565
566 Display *mDpy;
567
568 RetrievalFunc mFunc;
569
570 Matcher <int> mX;
571 Matcher <int> mY;
572 Matcher <unsigned int> mWidth;
573 Matcher <unsigned int> mHeight;
574 Matcher <unsigned int> mBorder;
575};
576
577Matcher <Window>
578ct::HasGeometry (Display *dpy,
579 RetrievalFunc func,
580 const Matcher <int> &x,
581 const Matcher <int> &y,
582 const Matcher <unsigned int> &width,
583 const Matcher <unsigned int> &height,
584 const Matcher <unsigned int> &border)
585{
586 return MakeMatcher (new WindowGeometryMatcher (dpy,
587 func,
588 x,
589 y,
590 width,
591 height,
592 border));
593}
594
595ct::WindowGeometryMatcher::WindowGeometryMatcher (Display *dpy,
596 RetrievalFunc func,
597 const Matcher <int> &x,
598 const Matcher <int> &y,
599 const Matcher <unsigned int> &width,
600 const Matcher <unsigned int> &height,
601 const Matcher <unsigned int> &border) :
602 priv (new Private (dpy, func, x, y, width, height, border))
603{
604}
605
606ct::WindowGeometryMatcher::Private::Private (Display *dpy,
607 RetrievalFunc func,
608 const Matcher <int> &x,
609 const Matcher <int> &y,
610 const Matcher <unsigned int> &width,
611 const Matcher <unsigned int> &height,
612 const Matcher <unsigned int> &border):
613 mDpy (dpy),
614 mFunc (func),
615 mX (x),
616 mY (y),
617 mWidth (width),
618 mHeight (height),
619 mBorder (border)
620{
621}
622
623bool
624ct::WindowGeometryMatcher::MatchAndExplain (Window w,
625 MatchResultListener *listener) const
626{
627 int x, y;
628 unsigned int width, height, border;
629
630 priv->mFunc (priv->mDpy, w, x, y, width, height, border);
631
632 bool match = priv->mX.MatchAndExplain (x, listener) &&
633 priv->mY.MatchAndExplain (y, listener) &&
634 priv->mWidth.MatchAndExplain (width, listener) &&
635 priv->mHeight.MatchAndExplain (height, listener) &&
636 priv->mBorder.MatchAndExplain (border, listener);
637
638 if (!match)
639 {
640 *listener << "Geometry:"
641 << " x: " << x
642 << " y: " << y
643 << " width: " << width
644 << " height: " << height
645 << " border: " << border;
646 }
647
648 return match;
649}
650
651void
652ct::WindowGeometryMatcher::DescribeTo (std::ostream *os) const
653{
654 *os << "Window geometry matching :";
655
656 *os << std::endl << " - ";
657 priv->mX.DescribeTo (os);
658
659 *os << std::endl << " - ";
660 priv->mY.DescribeTo (os);
661
662 *os << std::endl << " - ";
663 priv->mWidth.DescribeTo (os);
664
665 *os << std::endl << " - ";
666 priv->mHeight.DescribeTo (os);
667
668 *os << std::endl << " - ";
669 priv->mBorder.DescribeTo (os);
670}
671
515class ct::PrivateCompizProcess672class ct::PrivateCompizProcess
516{673{
517 public:674 public:
@@ -530,6 +687,9 @@
530 ct::CompizProcess::StartupFlags mFlags;687 ct::CompizProcess::StartupFlags mFlags;
531 bool mIsRunning;688 bool mIsRunning;
532 xorg::testing::Process mProcess;689 xorg::testing::Process mProcess;
690
691 std::string mPluginPaths;
692 std::auto_ptr <TmpEnv> mPluginPathsEnv;
533};693};
534694
535void695void
@@ -564,6 +724,26 @@
564 XSelectInput (dpy, root, attrib.your_event_mask);724 XSelectInput (dpy, root, attrib.your_event_mask);
565}725}
566726
727namespace
728{
729std::string PathForPlugin (const std::string &name,
730 ct::CompizProcess::PluginType type)
731{
732 switch (type)
733 {
734 case ct::CompizProcess::Real:
735 return compizRealPluginPath + name;
736 case ct::CompizProcess::TestOnly:
737 return compizTestOnlyPluginPath + name;
738 default:
739 throw std::logic_error ("Incorrect value for type");
740 }
741
742 return "";
743}
744
745}
746
567ct::CompizProcess::CompizProcess (::Display *dpy,747ct::CompizProcess::CompizProcess (::Display *dpy,
568 ct::CompizProcess::StartupFlags flags,748 ct::CompizProcess::StartupFlags flags,
569 const ct::CompizProcess::PluginList &plugins,749 const ct::CompizProcess::PluginList &plugins,
@@ -579,11 +759,17 @@
579759
580 args.push_back ("--send-startup-message");760 args.push_back ("--send-startup-message");
581761
582 /* Copy in plugin list */762 /* Copy in plugin list and set environment variables */
583 for (ct::CompizProcess::PluginList::const_iterator it = plugins.begin ();763 for (ct::CompizProcess::PluginList::const_iterator it = plugins.begin ();
584 it != plugins.end ();764 it != plugins.end ();
585 ++it)765 ++it)
586 args.push_back (*it);766 {
767 priv->mPluginPaths += PathForPlugin (it->name, it->type) + ":";
768 args.push_back (it->name);
769 }
770
771 priv->mPluginPathsEnv.reset (new TmpEnv ("COMPIZ_PLUGIN_DIR",
772 priv->mPluginPaths.c_str ()));
587773
588 priv->mProcess.Start (compizBinaryPath, args);774 priv->mProcess.Start (compizBinaryPath, args);
589 EXPECT_EQ (priv->mProcess.GetState (), xorg::testing::Process::RUNNING);775 EXPECT_EQ (priv->mProcess.GetState (), xorg::testing::Process::RUNNING);
@@ -703,14 +889,6 @@
703889
704class ct::PrivateAutostartCompizXorgSystemTest890class ct::PrivateAutostartCompizXorgSystemTest
705{891{
706 public:
707
708 PrivateAutostartCompizXorgSystemTest () :
709 overridePluginDirEnv ("COMPIZ_PLUGIN_DIR", compizOverridePluginPath.c_str ())
710 {
711 }
712
713 TmpEnv overridePluginDirEnv;
714};892};
715893
716ct::AutostartCompizXorgSystemTest::AutostartCompizXorgSystemTest () :894ct::AutostartCompizXorgSystemTest::AutostartCompizXorgSystemTest () :
@@ -727,7 +905,7 @@
727}905}
728906
729int907int
730ct::AutostartCompizXorgSystemTest::GetEventMask ()908ct::AutostartCompizXorgSystemTest::GetEventMask () const
731{909{
732 return 0;910 return 0;
733}911}
@@ -805,7 +983,7 @@
805}983}
806984
807int985int
808ct::AutostartCompizXorgSystemTestWithTestHelper::GetEventMask ()986ct::AutostartCompizXorgSystemTestWithTestHelper::GetEventMask () const
809{987{
810 return AutostartCompizXorgSystemTest::GetEventMask () |988 return AutostartCompizXorgSystemTest::GetEventMask () |
811 StructureNotifyMask;989 StructureNotifyMask;
@@ -837,6 +1015,7 @@
837ct::AutostartCompizXorgSystemTestWithTestHelper::GetPluginList ()1015ct::AutostartCompizXorgSystemTestWithTestHelper::GetPluginList ()
838{1016{
839 ct::CompizProcess::PluginList list;1017 ct::CompizProcess::PluginList list;
840 list.push_back ("testhelper");1018 list.push_back (ct::CompizProcess::Plugin ("testhelper",
1019 ct::CompizProcess::TestOnly));
841 return list;1020 return list;
842}1021}

Subscribers

People subscribed via source and target branches

to all changes: