summaryrefslogtreecommitdiff
path: root/beryl-plugins/src/inputzoom.c
diff options
context:
space:
mode:
authoronestone <onestone@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2006-11-20 16:58:41 +0000
committeronestone <onestone@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2006-11-20 16:58:41 +0000
commit476909cb4ab59ffdedb1c68558342a491382813b (patch)
tree0e0fb723a2a718255415f12ac302bbbe892303c9 /beryl-plugins/src/inputzoom.c
parent1938d27eda0b7c0677b41857d13f70a7dfbdc1cc (diff)
downloadmarex-dev-476909cb4ab59ffdedb1c68558342a491382813b.tar.gz
marex-dev-476909cb4ab59ffdedb1c68558342a491382813b.tar.bz2
beryl-plugins: inputzoom now works together with cube
git-svn-id: file:///beryl/trunk@1318 d7aaf104-2d23-0410-ae22-9d23157bf5a3
Diffstat (limited to 'beryl-plugins/src/inputzoom.c')
-rw-r--r--beryl-plugins/src/inputzoom.c132
1 files changed, 79 insertions, 53 deletions
diff --git a/beryl-plugins/src/inputzoom.c b/beryl-plugins/src/inputzoom.c
index f7b2307..da571aa 100644
--- a/beryl-plugins/src/inputzoom.c
+++ b/beryl-plugins/src/inputzoom.c
@@ -107,6 +107,7 @@ typedef struct _ZoomScreen
PaintScreenProc paintScreen;
PaintTransformedScreenProc paintTransformedScreen;
SetScreenOptionForPluginProc setScreenOptionForPlugin;
+ ApplyScreenTransformProc applyScreenTransform;
CompOption opt[ZOOM_SCREEN_OPTION_NUM];
@@ -401,6 +402,36 @@ adjustZoomVelocity (ZoomScreen * zs)
}
static void
+zoomApplyScreenTransform (CompScreen *s,
+ const ScreenPaintAttrib *sAttrib,
+ int output)
+{
+ ZOOM_SCREEN (s);
+
+ UNWRAP (zs, s, applyScreenTransform);
+ (*s->applyScreenTransform) (s, sAttrib, output);
+ WRAP (zs, s, applyScreenTransform, zoomApplyScreenTransform);
+
+ Bool *pCaps = (Bool *) IPCS_GetVPtrND (IPCS_OBJECT(s),
+ "cube_painting_caps_bool_ptr", NULL);
+ if (zs->active && (!pCaps || !(*pCaps)))
+ {
+ 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->yscale - 1);
+
+ glTranslatef (tx, ty, 0.0f);
+ glScalef ( zs->xscale, zs->yscale, 1.0f);
+ }
+}
+
+
+static void
zoomPreparePaintScreen (CompScreen * s, int msSinceLastPaint)
{
ZOOM_SCREEN (s);
@@ -446,9 +477,12 @@ zoomPreparePaintScreen (CompScreen * s, int msSinceLastPaint)
Window root_return;
Window child_return;
-
- XQueryPointer(s->display->display, s->root, &root_return, &child_return,
- &zs->mouseX, &zs->mouseY, &winX, &winY, &mask_return);
+ if (!otherScreenGrabExist (s, "scale", "switcher", 0))
+ {
+ XQueryPointer(s->display->display, s->root, &root_return,
+ &child_return, &zs->mouseX, &zs->mouseY, &winX, &winY,
+ &mask_return);
+ }
if (zs->currentScale == 1.0f && zs->zVelocity == 0.0f)
@@ -503,32 +537,10 @@ zoomPaintScreen (CompScreen * s,
if (zs->active)
{
- ScreenPaintAttrib sa = *sAttrib;
- int saveFilter;
-
- 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 (sa.xTranslate > 0.0f)
- sa.xRotate += 0.000001f;
- else
- sa.xRotate -= 0.000001f;
-
mask &= ~PAINT_SCREEN_REGION_MASK;
mask |= PAINT_SCREEN_TRANSFORMED_MASK | PAINT_SCREEN_CLEAR_MASK;
- saveFilter = s->filter[SCREEN_TRANS_FILTER];
+ int saveFilter = s->filter[SCREEN_TRANS_FILTER];
if (zs->opt[ZOOM_SCREEN_OPTION_FILTER_LINEAR].value.b ||
zs->zVelocity != 0.0f)
@@ -536,10 +548,42 @@ zoomPaintScreen (CompScreen * s,
else
s->filter[SCREEN_TRANS_FILTER] = COMP_TEXTURE_FILTER_FAST;
+ UNWRAP (zs, s, paintScreen);
+ status = (*s->paintScreen) (s, sAttrib, region, output, mask);
+ WRAP (zs, s, paintScreen, zoomPaintScreen);
+ s->filter[SCREEN_TRANS_FILTER] = saveFilter;
+ }
+ else
+ {
UNWRAP (zs, s, paintScreen);
- status = (*s->paintScreen) (s, &sa, region, output, mask);
+ status = (*s->paintScreen) (s, sAttrib, region, output, mask);
WRAP (zs, s, paintScreen, zoomPaintScreen);
+ }
+
+ return status;
+}
+
+static void
+zoomPaintTransformedScreen (CompScreen * s, const ScreenPaintAttrib * sa,
+ Region region, int output, unsigned int mask)
+{
+ ZOOM_SCREEN (s);
+ if (zs->active)
+ {
+ REGION r;
+ r.rects = &r.extents;
+ r.numRects = 1;
+ r.extents.x1 = zs->mouseX - (zs->mouseX / zs->xscale) +
+ (s->outputDev[output].region.extents.x1 / zs->xscale);
+ r.extents.y1 = zs->mouseY - (zs->mouseY / zs->yscale) +
+ (s->outputDev[output].region.extents.y1 / zs->yscale);
+ r.extents.x2 = r.extents.x1 + s->outputDev[output].width / zs->xscale;
+ r.extents.y2 = r.extents.y1 + s->outputDev[output].height / zs->yscale;
+
+ UNWRAP (zs, s, paintTransformedScreen);
+ (*s->paintTransformedScreen) (s, sa, &r, output, mask);
+ WRAP (zs, s, paintTransformedScreen, zoomPaintTransformedScreen);
if (zs->cursor.isSet)
{
@@ -572,30 +616,6 @@ zoomPaintScreen (CompScreen * s,
glDisable (GL_TEXTURE_RECTANGLE_ARB);
glPopMatrix ();
}
-
- s->filter[SCREEN_TRANS_FILTER] = saveFilter;
- }
- else
- {
- UNWRAP (zs, s, paintScreen);
- status = (*s->paintScreen) (s, sAttrib, region, output, mask);
- WRAP (zs, s, paintScreen, zoomPaintScreen);
- }
-
- return status;
-}
-
-static void
-zoomPaintTransformedScreen (CompScreen * s, const ScreenPaintAttrib * sa,
- Region region, int output, unsigned int mask)
-{
- ZOOM_SCREEN (s);
- if (zs->active)
- {
- UNWRAP (zs, s, paintTransformedScreen);
- (*s->paintTransformedScreen) (s, sa, &s->region, output, mask);
- WRAP (zs, s, paintTransformedScreen, zoomPaintTransformedScreen);
-
}
else
{
@@ -897,6 +917,7 @@ zoomInitScreen (CompPlugin * p, CompScreen * s)
WRAP (zs, s, paintScreen, zoomPaintScreen);
WRAP (zs, s, paintTransformedScreen, zoomPaintTransformedScreen);
WRAP (zs, s, setScreenOptionForPlugin, zoomSetScreenOptionForPlugin);
+ WRAP (zs, s, applyScreenTransform, zoomApplyScreenTransform);
s->privates[zd->screenPrivateIndex].ptr = zs;
@@ -923,6 +944,7 @@ zoomFiniScreen (CompPlugin * p, CompScreen * s)
UNWRAP (zs, s, paintScreen);
UNWRAP (zs, s, paintTransformedScreen);
UNWRAP (zs, s, setScreenOptionForPlugin);
+ UNWRAP (zs, s, applyScreenTransform);
removeScreenAction (s, &zd->opt[ZOOM_DISPLAY_OPTION_IN].value.action);
removeScreenAction (s, &zd->opt[ZOOM_DISPLAY_OPTION_OUT].value.action);
@@ -948,6 +970,10 @@ zoomFini (CompPlugin * p)
freeDisplayPrivateIndex (displayPrivateIndex);
}
+CompPluginDep zoomDeps[] = {
+ {CompPluginRuleBefore, "cube"},
+};
+
CompPluginFeature zoomFeatures[] = {
{"zoom"}
};
@@ -968,8 +994,8 @@ CompPluginVTable zoomVTable = {
zoomSetDisplayOption,
zoomGetScreenOptions,
zoomSetScreenOption,
- 0,
- 0,
+ zoomDeps,
+ sizeof (zoomDeps) / sizeof (zoomDeps[0]),
zoomFeatures,
sizeof (zoomFeatures) / sizeof (zoomFeatures[0]),
BERYL_ABI_INFO,