summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mikos <metastability@opencompositing.org>2008-01-11 14:35:35 +1030
committerDavid Mikos <metastability@opencompositing.org>2008-01-11 14:35:35 +1030
commitc8986593fc2b1af3ba507aa2d1d462b0f5cfa992 (patch)
tree19ba418728bda2a584c68ce2fbcd5436810fc3be
parentc7060d0cd7436e027e6acbf5bb6cbd72cefe913e (diff)
downloadrubik-c8986593fc2b1af3ba507aa2d1d462b0f5cfa992.tar.gz
rubik-c8986593fc2b1af3ba507aa2d1d462b0f5cfa992.tar.bz2
Add support for rotating windows about all axes.
-rw-r--r--rubik.c142
-rw-r--r--rubik.xml.in5
2 files changed, 66 insertions, 81 deletions
diff --git a/rubik.c b/rubik.c
index 67032aa..2f0ade6 100644
--- a/rubik.c
+++ b/rubik.c
@@ -284,21 +284,43 @@ static void rubikPaintInside (CompScreen *s,
//glEnable (GL_LIGHT1);
//glEnable (GL_LIGHT0);
- if (rs->w!=NULL && rs->initiated && rubikGetRotateDesktop(s)) {
+ if (rs->initiated && rubikGetRotateDesktop(s)) {
Bool coloredSides = rubikGetColoredSides(s);
- int k;
- for (k=0; k < (coloredSides ? 1 : rs->numDesktopWindows); k++) {
-
+ int winCounter = 0;
+ CompWindow *w;
+
+ int numWindows=1;
+ if (!coloredSides) {
+ for (w = s->windows; w; w = w->next) {
+ if (w->destroyed) continue;
+ if (w->hidden) continue;
+ if (w->invisible) continue;
+ if (!w->desktop && !rubikGetPaintWindowContents(s)) continue;
+
+ numWindows++;
+ }
+ }
+
+ for (w = s->windows; w; w = w->next) {
if (!coloredSides) {
- if ((*rs->w[k]).destroyed) continue;
- if ((*rs->w[k]).hidden) continue;
- enableTexture (s, (*rs->w[k]).texture,
+ if (w->destroyed) continue;
+ if (w->hidden) continue;
+ if (w->invisible) continue;
+ if (!w->desktop && !rubikGetPaintWindowContents(s)) continue;
+
+ enableTexture (s, w->texture,
COMP_TEXTURE_FILTER_GOOD);
- glEnable ((*rs->w[k]).texture->target);
+ glEnable (w->texture->target);
}
+ else {
+ if (winCounter>0)
+ break;
+ }
+ winCounter++;
+
glEnable (GL_NORMALIZE);
glDisable (GL_COLOR_MATERIAL);
glDisable (GL_CULL_FACE);
@@ -309,12 +331,11 @@ static void rubikPaintInside (CompScreen *s,
glEnable (GL_COLOR_MATERIAL);
glDisable (GL_TEXTURE_2D);
}
- //glColor4f (0.4, 0.3, 0.0, 1.0);
// draw texture
- float width = ((float) (*rs->w[k]).width) /((float) s->width);
- float height = ((float) (*rs->w[k]).height)/((float) s->height);
+ float width = ((float) w->width) /((float) s->width);
+ float height = ((float) w->height)/((float) s->height);
if (coloredSides) {
width = 1;
@@ -345,6 +366,12 @@ static void rubikPaintInside (CompScreen *s,
glColor4fv (rs->faces[square->side].color);
else if (!rubikGetDesktopCaps(s) && square->side>=4)
continue;
+ else if (!w->desktop) {
+ float winX = WIN_REAL_X(w) + WIN_REAL_W(w)/2.0+w->screen->x*w->screen->width;
+ float screenW = w->screen->width;
+ if (((int) (winX/screenW))!=square->side)
+ continue;
+ }
glPushMatrix();
@@ -429,7 +456,7 @@ static void rubikPaintInside (CompScreen *s,
if (i==3)
glRotatef (face->side[index]*90, 0, 1, 0);
*/
- glTranslatef (0,0,0.5-0.00001*(k+1)); //allow for layers
+ glTranslatef (0,0,0.5-0.00005*(numWindows+1-winCounter)); //allow for layers
glTranslatef (-0.5,0,0);
@@ -445,8 +472,8 @@ static void rubikPaintInside (CompScreen *s,
glTranslatef (0,((float) hs+0.5 )/((float) vStrips),0);
if (!coloredSides) {
- glTranslatef (-((float) (*rs->w[k]).attrib.x)/((float) s->width),0,0);
- glTranslatef (0,-((float) (*rs->w[k]).attrib.y)/((float) s->height),0);
+ glTranslatef (-((float) w->attrib.x)/((float) s->width),0,0);
+ glTranslatef (0,-((float) w->attrib.y)/((float) s->height),0);
}
@@ -458,11 +485,11 @@ static void rubikPaintInside (CompScreen *s,
float y = 0;
if (!coloredSides)
- y = ((float) (*rs->w[k]).attrib.y)/((float) s->height);
+ y = ((float) w->attrib.y)/((float) s->height);
float x = 0;
if (!coloredSides)
- x = ((float) (*rs->w[k]).attrib.x)/((float) s->width);
+ x = ((float) w->attrib.x)/((float) s->width);
float wh1 = maximum (y, h1);
@@ -482,16 +509,24 @@ static void rubikPaintInside (CompScreen *s,
v2=x+width;
- if (wh1<wh2) {
+ if (wh1<wh2 && wv1<wv2) {
h1 -= y;
h2 = (h2-y)/height;
wh1-= y;
wh2-= y;
+
+
wh1+=((float) hs-square->y )/((float) hStrips);
wh2+=((float) hs-square->y )/((float) hStrips);
+ v1 -= x;
+ v2 = (v2-x)/width;
+ wv1+= x;
+ wv2+= x;
+
+
wv1+=((float) vs-square->x )/((float) vStrips);
wv2+=((float) vs-square->x )/((float) vStrips);
@@ -540,15 +575,15 @@ static void rubikPaintInside (CompScreen *s,
if (i==3)
glRotatef (-rs->th[0], 0, 0, 1);
- glTranslatef (0,0,0.5-0.00001*(k+1)); //allow for layers
+ glTranslatef (0,0,0.5-0.00005*(numWindows+1-winCounter)); //allow for layers
if (coloredSides) {
glTranslatef (-0.5,0,0);
glTranslatef (0,0.5,0);
}
else {
- glTranslatef (-((float) (*rs->w[k]).attrib.x)/((float) s->width)-0.5,0,0);
- glTranslatef (0,-((float) (*rs->w[k]).attrib.y)/((float) s->height)+0.5,0);
+ glTranslatef (-((float) w->attrib.x)/((float) s->width)-0.5,0,0);
+ glTranslatef (0,-((float) w->attrib.y)/((float) s->height)+0.5,0);
}
float s1 = ((float) vs )/((float) vStrips);
@@ -582,7 +617,7 @@ static void rubikPaintInside (CompScreen *s,
}
if (!coloredSides) {
- disableTexture (s, (*rs->w[k]).texture);
+ disableTexture (s, w->texture);
}
}
}
@@ -935,10 +970,10 @@ static Bool RubikPaintOutput(CompScreen *s, const ScreenPaintAttrib *sAttrib,
RUBIK_SCREEN(s);
- if(rs->initiated) {
+ //if(rs->initiated) {
mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK;
//mask |= PAINT_SCREEN_REGION_MASK;
- }
+ //}
UNWRAP(rs, s, paintOutput);
status = (*s->paintOutput)(s, sAttrib, transform, region, output, mask);
@@ -947,62 +982,6 @@ static Bool RubikPaintOutput(CompScreen *s, const ScreenPaintAttrib *sAttrib,
return status;
}
-static void
-RubikDrawWindowTexture(CompWindow * w, CompTexture * texture,
- const FragmentAttrib *attrib,
- unsigned int mask)
-{
- //RUBIK_WINDOW(w);
- RUBIK_SCREEN(w->screen);
-
- if (texture!=NULL && (w->desktop) && !w->hidden) {
-
- Bool newWindow = TRUE;
- int i;
- for (i=0; i<rs->numDesktopWindows; i++) {
- if (w->texture->name==(*rs->w[i]).texture->name) {
- newWindow = FALSE;
- }
- }
- if (newWindow) {
- rs->numDesktopWindows++;
- if (rs->w==NULL) {
- rs->w = malloc (sizeof(CompWindow*));
- rs->w[0] = w;
- }
- else { // insert new window and bubble sort list of pointers
- rs->w = realloc (rs->w, rs->numDesktopWindows*sizeof (CompWindow*));
-
- i = rs->numDesktopWindows - 1;
- while (i>0) {
- if (w->activeNum < (*rs->w[i-1]).activeNum) break;
- rs->w[i] = rs->w[i-1];
- i--;
- }
- rs->w[i] = w;
-
-
-
- /*if (w->texture->name > (*rs->w[rs->numDesktopWindows-2]).texture->name) {
- rs->w[rs->numDesktopWindows-1] = w;
- }
- else { //bubble sort
-
- rs->w[rs->numDesktopWindows-1] = rs->w[rs->numDesktopWindows-2];
- rs->w[rs->numDesktopWindows-2] = w;
- }*/
- }
- //printf ("new texture - %i\n",w->texture->name);
- //printf ("active num - %i\n\n", w->activeNum);
- }
- //printf ("%i\n",w->texture->name);
- }
-
- UNWRAP(rs, w->screen, drawWindowTexture);
- (*w->screen->drawWindowTexture) (w, texture, attrib, mask);
- WRAP(rs, w->screen, drawWindowTexture, RubikDrawWindowTexture);
-}
-
static Bool
RubikDrawWindow (CompWindow *w,
const CompTransform *transform,
@@ -1148,6 +1127,7 @@ static Bool RubikPaintWindow(CompWindow *w, const WindowPaintAttrib *attrib,
float winX = WIN_REAL_X(w) + WIN_REAL_W(w)/2.0+w->screen->x*w->screen->width;
float screenW = w->screen->width;
+
//printf ("\nwin: %f\n",winX);
//printf ("screen: %f\n",screenW);
@@ -1416,7 +1396,7 @@ rubikInitScreen (CompPlugin *p,
WRAP (rs, s, damageWindowRect, RubikDamageWindowRect);
WRAP (rs, s, addWindowGeometry, RubikAddWindowGeometry);
- WRAP (rs, s, drawWindowTexture, RubikDrawWindowTexture);
+ //WRAP (rs, s, drawWindowTexture, RubikDrawWindowTexture);
//WRAP (rs, s, disableOutputClipping, RubikDisableOutputClipping);
@@ -1444,7 +1424,7 @@ rubikFiniScreen (CompPlugin *p,
UNWRAP (rs, s, damageWindowRect);
UNWRAP (rs, s, addWindowGeometry);
- UNWRAP (rs, s, drawWindowTexture);
+ //UNWRAP (rs, s, drawWindowTexture);
//UNWRAP (rs, s, disableOutputClipping);
diff --git a/rubik.xml.in b/rubik.xml.in
index 98cba1b..b871d60 100644
--- a/rubik.xml.in
+++ b/rubik.xml.in
@@ -54,6 +54,11 @@
<long>Rotate desktop as well as windows.</long>
<default>true</default>
</option>
+ <option name="paint_window_contents" type="bool">
+ <short>Paint window contents</short>
+ <long>Display the windows when initiated (without frames).</long>
+ <default>false</default>
+ </option>
<option name="colored_sides" type="bool">
<short>Colored Sides</short>
<long>Replace wallpaper with colored sides.</long>