~smspillaz/compiz-core/compiz-core.fix_939228

« back to all changes in this revision

Viewing changes to src/screen.cpp

  • Committer: smspillaz
  • Date: 2012-04-24 09:19:39 UTC
  • Revision ID: sam.spilsbury@canonical.com-20120424091939-xu63eefd1vx7she1
Don't return a negative value for CompScreen::viewportForGeometry

Fix LP#939288 - If a window was partially on a viewport which was the last
one in its row or column, and we were on the viewport on the opposite side
of that row or column, compiz would work backwards to find the position
of the window (which would be negative) and return a negative viewport
position. This caused plugins like wall to behave strangely 

Show diffs side-by-side

added added

removed removed

Lines of Context:
4065
4065
   is currently computed as the viewport where the center of the window is
4066
4066
   located. */
4067
4067
void
4068
 
CompScreenImpl::viewportForGeometry (const CompWindow::Geometry& gm,
4069
 
                                 CompPoint&                  viewport)
 
4068
compiz::private_screen::viewports::viewportForGeometry (const CompWindow::Geometry &gm,
 
4069
                                                        CompPoint                  &viewport,
 
4070
                                                        ViewportRetrievalInterface *viewports,
 
4071
                                                        const CompSize &           screenSize)
4070
4072
{
4071
4073
    CompRect rect (gm);
4072
4074
    int      offset;
4073
4075
 
 
4076
    const CompPoint &vp = viewports->getCurrentViewport ();
 
4077
    const CompSize &vpSize = viewports->viewportDimentions ();
 
4078
 
4074
4079
    rect.setWidth  (gm.widthIncBorders ());
4075
4080
    rect.setHeight (gm.heightIncBorders ());
4076
4081
 
4077
4082
    offset = rect.centerX () < 0 ? -1 : 0;
4078
 
    viewport.setX (priv->vp.x () + ((rect.centerX () / width ()) + offset) %
4079
 
                   priv->vpSize.width ());
 
4083
    viewport.setX (compiz::core::screen::wraparound_mod (vp.x () + ((rect.centerX () / screenSize.width ()) + offset), vpSize.width ()));
4080
4084
 
4081
4085
    offset = rect.centerY () < 0 ? -1 : 0;
4082
 
    viewport.setY (priv->vp.y () + ((rect.centerY () / height ()) + offset ) %
4083
 
                   priv->vpSize.height ());
 
4086
    viewport.setY (compiz::core::screen::wraparound_mod (vp.y () + ((rect.centerY () / screenSize.height ()) + offset), vpSize.height ()));
 
4087
}
 
4088
 
 
4089
void
 
4090
CompScreenImpl::viewportForGeometry (const CompWindow::Geometry& gm,
 
4091
                                     CompPoint&                  viewport)
 
4092
{
 
4093
    compiz::private_screen::viewports::viewportForGeometry (gm, viewport, priv.get (), *this);
4084
4094
}
4085
4095
 
4086
4096
int