rendered paste bodydiff --git a/plugins/cube.c b/plugins/cube.c
index 3292248..92e035d 100644
--- a/plugins/cube.c
+++ b/plugins/cube.c
@@ -1693,13 +1693,13 @@ cubePaintBackground (CompScreen *s,
Region region,
unsigned int mask)
{
- int n;
+ int numBg;
CUBE_SCREEN (s);
cubeSetBackgroundOpacity (s);
- n = cs->opt[CUBE_SCREEN_OPTION_BACKGROUNDS].value.list.nValue;
+ numBg = cs->opt[CUBE_SCREEN_OPTION_BACKGROUNDS].value.list.nValue;
if (n)
{
CompTexture *bg;
@@ -1707,6 +1707,7 @@ cubePaintBackground (CompScreen *s,
BoxPtr pBox = region->rects;
int nBox = region->numRects;
GLfloat *d, *data;
+ int n;
if (!nBox)
{
@@ -1714,7 +1715,9 @@ cubePaintBackground (CompScreen *s,
return;
}
- n = (s->x * cs->nOutput + cs->srcOutput) % n;
+ n = s->x - (s->windowOffsetX / s->width);
+ n = (n * cs->nOutput + cs->srcOutput) % numBg;
+ while (n < 0) n += numBg;
if (s->desktopWindowCount)
{