summaryrefslogtreecommitdiff
path: root/beryl-plugins/src/inputzoom.c
diff options
context:
space:
mode:
authoronestone <onestone@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2006-11-14 09:47:21 +0000
committeronestone <onestone@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2006-11-14 09:47:21 +0000
commit21a390b8aa27cff05fd2353b91eb698c64a372e9 (patch)
tree5e2aba1be9f12e926624a0e16501ce24401d15da /beryl-plugins/src/inputzoom.c
parent687619cdb5a8652de8a574f8e3961e44dba1201c (diff)
downloadmarex-dev-21a390b8aa27cff05fd2353b91eb698c64a372e9.tar.gz
marex-dev-21a390b8aa27cff05fd2353b91eb698c64a372e9.tar.bz2
beryl-plugins: inputzoom: added multimonitor support
git-svn-id: file:///beryl/trunk@1187 d7aaf104-2d23-0410-ae22-9d23157bf5a3
Diffstat (limited to 'beryl-plugins/src/inputzoom.c')
-rwxr-xr-xberyl-plugins/src/inputzoom.c66
1 files changed, 49 insertions, 17 deletions
diff --git a/beryl-plugins/src/inputzoom.c b/beryl-plugins/src/inputzoom.c
index 9667237..2c1812c 100755
--- a/beryl-plugins/src/inputzoom.c
+++ b/beryl-plugins/src/inputzoom.c
@@ -105,6 +105,7 @@ typedef struct _ZoomScreen
PreparePaintScreenProc preparePaintScreen;
DonePaintScreenProc donePaintScreen;
PaintScreenProc paintScreen;
+ PaintTransformedScreenProc paintTransformedScreen;
SetScreenOptionForPluginProc setScreenOptionForPlugin;
CompOption opt[ZOOM_SCREEN_OPTION_NUM];
@@ -119,10 +120,6 @@ typedef struct _ZoomScreen
GLfloat zVelocity;
- GLfloat xtrans;
- GLfloat ytrans;
- GLfloat ztrans;
-
GLfloat xscale;
GLfloat yscale;
@@ -176,12 +173,24 @@ updateCursor (Display *dpy,CursorTexture * cursor)
cursor->hotX = ci->xhot;
cursor->hotY = ci->yhot;
+ unsigned char *pixels = malloc(ci->width * ci->height * 4);
+ int i;
+ for (i = 0; i < ci->width * ci->height; i++)
+ {
+ unsigned long pix = ci->pixels[i];
+ pixels[i * 4] = pix & 0xff;
+ pixels[(i * 4) + 1] = (pix >> 8) & 0xff;
+ pixels[(i * 4) + 2] = (pix >> 16) & 0xff;
+ pixels[(i * 4) + 3] = (pix >> 24) & 0xff;
+ }
+
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, cursor->texture);
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0 , GL_RGBA, cursor->width, cursor->height,
- 0, GL_BGRA, GL_UNSIGNED_BYTE, ci->pixels);
+ 0, GL_BGRA, GL_UNSIGNED_BYTE, pixels);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
glDisable (GL_TEXTURE_RECTANGLE_ARB);
XFree (ci);
+ free (pixels);
}
static void
@@ -189,7 +198,7 @@ freeCursor (CursorTexture * cursor)
{
if (!cursor->isSet)
return;
- cursor->isSet = FALSE;glEnable (GL_TEXTURE_RECTANGLE_ARB);
+ cursor->isSet = FALSE;
glDeleteTextures (1, &cursor->texture);
cursor->texture = 0;
}
@@ -441,9 +450,6 @@ zoomPreparePaintScreen (CompScreen * s, int msSinceLastPaint)
XQueryPointer(s->display->display, s->root, &root_return, &child_return,
&zs->mouseX, &zs->mouseY, &winX, &winY, &mask_return);
- zs->xtrans = -((((zs->mouseX - (s->width / 2.0))) / (s->width)) * zs->xscale - ((zs->mouseX - (s->width / 2.0)) / (s->width)));
- zs->ytrans = ((((zs->mouseY - (s->height / 2.0))) / (s->height)) * zs->yscale - (((zs->mouseY - (s->height / 2.0))) / (s->height)));
-
if (zs->currentScale == 1.0f && zs->zVelocity == 0.0f)
{
@@ -500,14 +506,21 @@ zoomPaintScreen (CompScreen * s,
ScreenPaintAttrib sa = *sAttrib;
int saveFilter;
- sa.xTranslate += zs->xtrans;
- sa.yTranslate += zs->ytrans;
+ float tx = zs->mouseX - (s->outputDev[output].region.extents.x1 + (s->outputDev[output].width / 2.0));
+ float ty = zs->mouseY - (s->outputDev[output].region.extents.y1 + (s->outputDev[output].height / 2.0));
+ tx /= s->outputDev[output].width;
+ tx = -(tx * (zs->xscale - 1));
+ ty /= s->outputDev[output].height;
+ ty = ty * (zs->xscale - 1);
+
+ sa.xTranslate += tx;
+ sa.yTranslate += ty;
sa.xScale = zs->xscale;
sa.yScale = zs->yscale;
/* hack to get sides rendered correctly */
- if (zs->xtrans > 0.0f)
+ if (sa.xTranslate > 0.0f)
sa.xRotate += 0.000001f;
else
sa.xRotate -= 0.000001f;
@@ -532,9 +545,7 @@ zoomPaintScreen (CompScreen * s,
{
glPushMatrix ();
glLoadIdentity ();
- glTranslatef (-0.5f, -0.5f, -DEFAULT_Z_CAMERA);
- glScalef (1.0f / s->width, -1.0f / s->height, 1.0f);
- glTranslatef (0.0f, -s->height, 0.0f);
+ prepareXCoords (s, output, -DEFAULT_Z_CAMERA);
glTranslatef (zs->mouseX, zs->mouseY, 0.0);
glScalef (zs->xscale, zs->yscale, 1.0f);
@@ -557,9 +568,8 @@ zoomPaintScreen (CompScreen * s,
glDisable (GL_BLEND);
- glDisable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
-
+ glDisable (GL_TEXTURE_RECTANGLE_ARB);
glPopMatrix ();
}
@@ -575,6 +585,26 @@ zoomPaintScreen (CompScreen * s,
return status;
}
+static void
+zoomPaintTransformedScreen (CompScreen * s, const ScreenPaintAttrib * sa,
+ int output, Bool clipToOutput, unsigned int mask)
+{
+ ZOOM_SCREEN (s);
+ if (zs->active)
+ {
+ UNWRAP (zs, s, paintTransformedScreen);
+ (*s->paintTransformedScreen) (s, sa, output, FALSE, mask);
+ WRAP (zs, s, paintTransformedScreen, zoomPaintTransformedScreen);
+
+ }
+ else
+ {
+ UNWRAP (zs, s, paintTransformedScreen);
+ (*s->paintTransformedScreen) (s, sa, output, clipToOutput, mask);
+ WRAP (zs, s, paintTransformedScreen, zoomPaintTransformedScreen);
+ }
+}
+
static Bool
zoomIn (CompDisplay * d,
CompAction * action,
@@ -865,6 +895,7 @@ zoomInitScreen (CompPlugin * p, CompScreen * s)
WRAP (zs, s, preparePaintScreen, zoomPreparePaintScreen);
WRAP (zs, s, donePaintScreen, zoomDonePaintScreen);
WRAP (zs, s, paintScreen, zoomPaintScreen);
+ WRAP (zs, s, paintTransformedScreen, zoomPaintTransformedScreen);
WRAP (zs, s, setScreenOptionForPlugin, zoomSetScreenOptionForPlugin);
s->privates[zd->screenPrivateIndex].ptr = zs;
@@ -889,6 +920,7 @@ zoomFiniScreen (CompPlugin * p, CompScreen * s)
UNWRAP (zs, s, preparePaintScreen);
UNWRAP (zs, s, donePaintScreen);
UNWRAP (zs, s, paintScreen);
+ UNWRAP (zs, s, paintTransformedScreen);
UNWRAP (zs, s, setScreenOptionForPlugin);
free (zs);