All pastes #403380 Raw Edit

Someone

public text v1 · immutable
·published 2007-03-20 10:03 UTC
rendered paste body
diff --git a/configure.ac b/configure.ac
index 7b3863c..4c189f7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9,7 +9,7 @@ AC_CONFIG_HEADER([config.h])
 AM_MAINTAINER_MODE
 
 /* decorator interface version */
-AC_DEFINE(DECOR_INTERFACE_VERSION, 20061011, [Decorator interface version])
+AC_DEFINE(DECOR_INTERFACE_VERSION, 20070319, [Decorator interface version])
 
 AC_ISC_POSIX
 AC_PROG_CC
diff --git a/include/decoration.h b/include/decoration.h
index 755514c..a3f76dd 100644
--- a/include/decoration.h
+++ b/include/decoration.h
@@ -49,10 +49,13 @@ extern "C" {
 #define CLAMP_HORZ (1 << 0)
 #define CLAMP_VERT (1 << 1)
 
-#define XX_MASK (1 << 12)
-#define XY_MASK (1 << 13)
-#define YX_MASK (1 << 14)
-#define YY_MASK (1 << 15)
+#define STRETCH_X (1 << 0)
+#define STRETCH_Y (1 << 1)
+
+#define XX_MASK (1 << 16)
+#define XY_MASK (1 << 17)
+#define YX_MASK (1 << 18)
+#define YY_MASK (1 << 19)
 
 #define PAD_TOP    (1 << 0)
 #define PAD_BOTTOM (1 << 1)
@@ -78,6 +81,7 @@ typedef struct _decor_quad {
     int		   max_height;
     int		   align;
     int		   clamp;
+    int            stretch;
     decor_matrix_t m;
 } decor_quad_t;
 
diff --git a/libdecoration/decoration.c b/libdecoration/decoration.c
index 54ba1e4..8d4271e 100644
--- a/libdecoration/decoration.c
+++ b/libdecoration/decoration.c
@@ -109,6 +109,7 @@ decor_quads_to_property (long		 *data,
 	    (quad->p2.gravity << 4)    |
 	    (quad->align      << 8)    |
 	    (quad->clamp      << 10)   |
+	    (quad->stretch    << 12)   |
 	    (quad->m.xx ? XX_MASK : 0) |
 	    (quad->m.xy ? XY_MASK : 0) |
 	    (quad->m.yx ? YX_MASK : 0) |
@@ -177,8 +178,9 @@ decor_property_to_quads (long		 *data,
 	quad->p1.gravity = (flags >> 0) & 0xf;
 	quad->p2.gravity = (flags >> 4) & 0xf;
 
-	quad->align = (flags >> 8)  & 0x3;
-	quad->clamp = (flags >> 10) & 0x3;
+	quad->align   = (flags >> 8)  & 0x3;
+	quad->clamp   = (flags >> 10) & 0x3;
+	quad->stretch = (flags >> 12) & 0x3;
 
 	quad->m.xx = (flags & XX_MASK) ? 1.0f : 0.0f;
 	quad->m.xy = (flags & XY_MASK) ? 1.0f : 0.0f;
@@ -409,6 +411,7 @@ decor_set_vert_quad_row (decor_quad_t *q,
     q->max_height = top + top_corner;
     q->align	  = ALIGN_TOP;
     q->clamp	  = CLAMP_VERT;
+    q->stretch    = 0;
     q->m.x0	  = x0;
     q->m.y0	  = y0;
 
@@ -439,6 +442,7 @@ decor_set_vert_quad_row (decor_quad_t *q,
     q->max_height = SHRT_MAX;
     q->align	  = 0;
     q->clamp	  = CLAMP_VERT;
+    q->stretch    = 0;
 
     if (rotation)
     {
@@ -471,6 +475,7 @@ decor_set_vert_quad_row (decor_quad_t *q,
     q->max_height = bottom_corner + bottom;
     q->align	  = ALIGN_BOTTOM;
     q->clamp	  = CLAMP_VERT;
+    q->stretch    = 0;
 
     if (rotation)
     {
@@ -523,6 +528,7 @@ decor_set_horz_quad_line (decor_quad_t *q,
     q->max_height = SHRT_MAX;
     q->align	  = ALIGN_LEFT;
     q->clamp	  = 0;
+    q->stretch    = 0;
     q->m.xx	  = 1.0;
     q->m.xy	  = 0.0;
     q->m.yx	  = 0.0;
@@ -542,6 +548,7 @@ decor_set_horz_quad_line (decor_quad_t *q,
     q->max_height = SHRT_MAX;
     q->align	  = 0;
     q->clamp	  = 0;
+    q->stretch    = 0;
     q->m.xx	  = 0.0;
     q->m.xy	  = 0.0;
     q->m.yx	  = 0.0;
@@ -561,6 +568,7 @@ decor_set_horz_quad_line (decor_quad_t *q,
     q->max_height = SHRT_MAX;
     q->align	  = ALIGN_RIGHT;
     q->clamp	  = 0;
+    q->stretch    = 0;
     q->m.xx	  = 1.0;
     q->m.xy	  = 0.0;
     q->m.yx	  = 0.0;
diff --git a/plugins/decoration.c b/plugins/decoration.c
index 0e9003f..9b2176a 100644
--- a/plugins/decoration.c
+++ b/plugins/decoration.c
@@ -73,6 +73,8 @@ typedef struct _Decoration {
 
 typedef struct _ScaledQuad {
     CompMatrix matrix;
+    double     sx;
+    double     sy;
     BoxRec     box;
 } ScaledQuad;
 
@@ -325,9 +327,13 @@ computeQuadBox (decor_quad_t *q,
 		int	     *return_x1,
 		int	     *return_y1,
 		int	     *return_x2,
-		int	     *return_y2)
+		int	     *return_y2,
+		double       *return_sx,
+		double       *return_sy)
 {
     int x1, y1, x2, y2;
+    double sx = 1.0f;
+    double sy = 1.0f;
 
     decor_apply_gravity (q->p1.gravity, q->p1.x, q->p1.y, width, height,
 			 &x1, &y1);
@@ -350,7 +356,11 @@ computeQuadBox (decor_quad_t *q,
 	    y2 = height;
     }
 
-    if (q->max_width < x2 - x1)
+    if (q->stretch & STRETCH_X)
+    {
+	sx = (double)q->max_width / ((double)(x2 - x1));
+    }
+    else if (q->max_width < x2 - x1)
     {
 	if (q->align & ALIGN_RIGHT)
 	    x1 = x2 - q->max_width;
@@ -358,7 +368,11 @@ computeQuadBox (decor_quad_t *q,
 	    x2 = x1 + q->max_width;
     }
 
-    if (q->max_height < y2 - y1)
+    if (q->stretch & STRETCH_Y)
+    {
+	sy = (double)q->max_height / ((double)(y2 - y1));
+    }
+    else if (q->max_height < y2 - y1)
     {
 	if (q->align & ALIGN_BOTTOM)
 	    y1 = y2 - q->max_height;
@@ -370,6 +384,11 @@ computeQuadBox (decor_quad_t *q,
     *return_y1 = y1;
     *return_x2 = x2;
     *return_y2 = y2;
+
+    if (return_sx)
+	*return_sx = sx;
+    if (return_sy)
+	*return_sy = sy;
 }
 
 static Decoration *
@@ -467,7 +486,8 @@ decorCreateDecoration (CompScreen *screen,
 
     while (nQuad--)
     {
-	computeQuadBox (quad, minWidth, minHeight, &x1, &y1, &x2, &y2);
+	computeQuadBox (quad, minWidth, minHeight, &x1, &y1, &x2, &y2,
+			NULL, NULL);
 
 	if (x1 < left)
 	    left = x1;
@@ -573,19 +593,28 @@ setDecorationMatrices (CompWindow *w)
 
     for (i = 0; i < wd->nQuad; i++)
     {
-	wd->quad[i].matrix = wd->decor->texture->texture.matrix;
-
-	x0 = wd->decor->quad[i].m.x0;
-	y0 = wd->decor->quad[i].m.y0;
-
-	wd->quad[i].matrix.x0 += x0 * wd->quad[i].matrix.xx;
-	wd->quad[i].matrix.y0 += y0 * wd->quad[i].matrix.yy;
+	decor_matrix_t a;
+	CompMatrix b;
 
-	wd->quad[i].matrix.xy = wd->decor->quad[i].m.xy * wd->quad[i].matrix.xx;
-	wd->quad[i].matrix.yx = wd->decor->quad[i].m.yx * wd->quad[i].matrix.yy;
-
-	wd->quad[i].matrix.xx *= wd->decor->quad[i].m.xx;
-	wd->quad[i].matrix.yy *= wd->decor->quad[i].m.yy;
+	wd->quad[i].matrix = wd->decor->texture->texture.matrix;
+ 
+ 	x0 = wd->decor->quad[i].m.x0;
+ 	y0 = wd->decor->quad[i].m.y0;
+ 
+	a = wd->decor->quad[i].m;
+	b = wd->quad[i].matrix;
+ 
+	wd->quad[i].matrix.xx = a.xx * b.xx + a.yx * b.xy;
+	wd->quad[i].matrix.yx = a.xx * b.yx + a.yx * b.yy;
+	wd->quad[i].matrix.xy = a.xy * b.xx + a.yy * b.xy;
+	wd->quad[i].matrix.yy = a.xy * b.yx + a.yy * b.yy;
+	wd->quad[i].matrix.x0 = x0 * b.xx + y0 * b.xy + b.x0;
+	wd->quad[i].matrix.y0 = x0 * b.yx + y0 * b.yy + b.y0;
+
+	wd->quad[i].matrix.xx *= wd->quad[i].sx;
+	wd->quad[i].matrix.yx *= wd->quad[i].sx;
+	wd->quad[i].matrix.xy *= wd->quad[i].sy;
+	wd->quad[i].matrix.yy *= wd->quad[i].sy;
 
 	if (wd->decor->quad[i].align & ALIGN_RIGHT)
 	    x0 = wd->quad[i].box.x2 - wd->quad[i].box.x1;
@@ -620,6 +649,7 @@ updateWindowDecorationScale (CompWindow *w)
 {
     WindowDecoration *wd;
     int		     x1, y1, x2, y2;
+    double           sx, sy;
     int		     i;
 
     DECOR_WINDOW (w);
@@ -631,12 +661,14 @@ updateWindowDecorationScale (CompWindow *w)
     for (i = 0; i < wd->nQuad; i++)
     {
 	computeQuadBox (&wd->decor->quad[i], w->width, w->height,
-			&x1, &y1, &x2, &y2);
+			&x1, &y1, &x2, &y2, &sx, &sy);
 
 	wd->quad[i].box.x1 = x1 + w->attrib.x;
 	wd->quad[i].box.y1 = y1 + w->attrib.y;
 	wd->quad[i].box.x2 = x2 + w->attrib.x;
 	wd->quad[i].box.y2 = y2 + w->attrib.y;
+	wd->quad[i].sx     = sx;
+	wd->quad[i].sy     = sy;
     }
 
     setDecorationMatrices (w);