This email list is read-only. Emails sent to this list will be discarded
----------------------------------
four-corners/TODO | 7 +-
four-corners/fc.c | 502 +++++++++++++++++++++++++++---------------------
four-corners/fc.xml.in | 35 ++++-
3 files changed, 318 insertions(+), 226 deletions(-)
New commits:
commit 72e9a7a8d5dbbce62fc9d3433a107661f67480ae
Author: Shane Bryan <[EMAIL PROTECTED]>
Date: Fri Aug 1 05:18:12 2008 -0700
- Completely re-wrote how the animation transitions were happening. The
solution is not much more simple and robust
- Added some new ccsm config options, animation speed (implimented), opacity
for hidden/shown (not hooked up yet) and a scale factor for the hidden
buttons (also not hooked up yet)
- General cleanup of code, comments and simplification where I saw the need
Signed-off-by: Shane Bryan <[EMAIL PROTECTED]>
commit 9de8b8af5141b46d39ed81cf2d50ea54be7e6ac0
Author: Shane Bryan <[EMAIL PROTECTED]>
Date: Thu Jul 24 15:45:20 2008 -0700
- Fixed problem with buttons moving too far into the screen area if
fullscree/non-fullscreen events happen to freaquently.
Signed-off-by: Shane Bryan <[EMAIL PROTECTED]>
Diff in this email is a maximum of 400 lines.
diff --git a/four-corners/TODO b/four-corners/TODO
index 04c7192..987b7a7 100644
--- a/four-corners/TODO
+++ b/four-corners/TODO
@@ -2,10 +2,11 @@
Moblin Four Courners Compiz plugin TODO list:
- add corner app triggering mechanism
-- when app goes fullscreen, fade out and translate them off screen
-
- Add option to each corner to enable or disable it
+- Add user configurable keybinding mapping to trigger button "press" events in
+ addition to mouse based events
+
- cool visualizations (lighting, motion, shadows) on buttons when interesting
events happen on/near them
@@ -15,6 +16,8 @@ Moblin Four Courners Compiz plugin TODO list:
- Make button transition parameters (time, interval) settable via options
+- Add opacity and scaling factors to hide/show transitions
+
- Something is not working right with flat-file based options and getting
change
notify events when they are changed manually (like with an editor (vi, nano,
gedit, emacs) or text parsers (sed). Changes made with ccsm and (purportedly,
diff --git a/four-corners/fc.c b/four-corners/fc.c
index d903ea8..fb07600 100644
--- a/four-corners/fc.c
+++ b/four-corners/fc.c
@@ -56,14 +56,27 @@ typedef struct _FCButton {
int y1; // button upper left Y screen coord
int x2; // button lower right X screen coord
int y2; // button lower right Y screen coord
- int xd; // transition x delta
- int yd; // transition y delta
int bWidth; // button width
int bHeight; // button height
unsigned int tWidth; // texture width
unsigned int tHeight; // texture height
+ Region bRegion; // region that defines the button dimensions
+ Region transRegion; // region that defines the translation area
+ int ox; // original X screen coord
+ int oy; // original Y screen coord
+ int dx; // destination (hidden) X screen coord
+ int dy; // destination (hidden) Y screen coord
float sx; // scale factor in X
float sy; // scale factor in Y
+ float opacity; // current opacity value
+ float opacityRamp; // ramp factor for opacity changes (when/if used)
+ float visibleOpacity; // target opacity value to end at when showing
+ float hiddenOpacity; // target opacity value to end at when hiding
+ // - assumes full opacity when fully shown
+ float scale; // current scale value
+ float scaleRamp; // ramp factor for scale changes (when/if used)
+ float hiddenScale; // target scale value to end at when hiding.
+ // - assumes scale of 1.0 when fully shown
} FCButton, *pFCButton;
typedef struct _FCCorner {
@@ -89,6 +102,7 @@ typedef struct _FCDisplay {
} FCDisplay;
typedef struct _FCScreen {
+ PreparePaintScreenProc preparePaintScreen;
PaintOutputProc paintOutput;
DonePaintScreenProc donePaintScreen;
@@ -96,13 +110,21 @@ typedef struct _FCScreen {
int windowPrivateIndex;
Bool hiding;
Bool showing;
- int lastStep;
- int maxStep;
- int maxTransitionTime;
- int transitionInterval;
- CompTimeoutHandle showHideCornersTimerHandle;
+ int transTime;
+ struct timeval startTime;
+ struct timeval lastTime;
} FCScreen;
+#define ROUND(n) \
+ ((n) >= 0 ? (long)((n) + 0.5) : (long)((n) - 0.5))
+
+#define DIFFTIMEMS(t1, t2)
\
+ (((t1)->tv_sec==(t2)->tv_sec||(t1)->tv_usec>=(t2)->tv_usec)? \
+ ((((t1)->tv_sec-(t2)->tv_sec)*1000000)+ \
+ ((t1)->tv_usec-(t2)->tv_usec))/1000: \
+ ((((t1)->tv_sec-1-(t2)->tv_sec)*1000000)+ \
+ (1000000+(t1)->tv_usec-(t2)->tv_usec))/1000)
+
#define GET_FC_DISPLAY(d) \
((FCDisplay *) (d)->base.privates[displayPrivateIndex].ptr)
@@ -192,21 +214,12 @@ static void fcButtonReleased(int g)
// Point collision detection
static Bool fcPointInButton (int x, int y, int *g)
{
- Region r;
int i=0;
Bool hit = FALSE;
- r = XCreateRegion();
-
for (i=0; i<4; i++)
{
- r->extents.x1 = corners[i].button->x1;
- r->extents.y1 = corners[i].button->y1;
- r->extents.x2 = corners[i].button->x2;
- r->extents.y2 = corners[i].button->y2;
- r->rects = &r->extents;
- r->numRects = r->size = 1;
- if (XPointInRegion(r,x,y))
+ if (XPointInRegion(corners[i].button->bRegion,x,y))
{
*g = FCGravity[i];
hit = TRUE;
@@ -236,10 +249,19 @@ static Bool fcRegionInButton (Region r, int g)
// Given new location, re-calc locations and scaling factors
static void fcRelocateButton (FCButton *b, int newX, int newY)
{
- b->x1 = newX;
- b->y1 = newY;
- b->x2 = b->x1+b->bWidth;
- b->y2 = b->y1+b->bHeight;
+ //=================================================================
+ // Testing for both region inclusion as well as vertex intersection
+ // since "regions" are not inclusive of their vertices
+ //=================================================================
+ if (XPointInRegion(b->transRegion,newX,newY) ||
+ (newX == b->dx) || (newX == b->ox) ||
+ (newY == b->dy) || (newY == b->oy))
+ {
+ b->x1 = newX;
+ b->x2 = b->x1+b->bWidth;
+ b->y1 = newY;
+ b->y2 = b->y1+b->bHeight;
+ }
}
// Given new dimensions, re-calc locations and scaling factors
@@ -278,44 +300,95 @@ static void fcResizeButton (FCButton *b, int w, int h)
b->bWidth = w;
b->bHeight = h;
+ b->transRegion = XCreateRegion();
+ b->transRegion->rects = &b->transRegion->extents;
+ b->transRegion->numRects = 1;
// Based on gravity, assign sourece x1,y1,x2,y2 values
switch (b->gravity) {
case NW:
// Place the button in the upper left corner
- b->x1 = 0;
- b->y1 = 0;
- b->x2 = b->x1+b->bWidth;
- b->y2 = b->y1+b->bHeight;
+ b->ox = 0;
+ b->oy = 0;
+ b->x1 = b->ox;
+ b->y1 = b->oy;
+ b->x2 = b->ox+b->bWidth;
+ b->y2 = b->oy+b->bHeight;
+ b->dx = b->ox-b->bWidth;
+ b->dy = b->oy-b->bHeight;
+ b->transRegion->extents.x1 = b->dx;
+ b->transRegion->extents.y1 = b->dy;
+ b->transRegion->extents.x2 = b->ox;
+ b->transRegion->extents.y2 = b->oy;
break;
case NE:
// Place the button in the upper right corner
- b->x1 = fcScreenWidth - b->bWidth;
- b->y1 = 0;
- b->x2 = b->x1+b->bWidth;
- b->y2 = b->y1+b->bHeight;
+ b->ox = fcScreenWidth - b->bWidth;
+ b->oy = 0;
+ b->x1 = b->ox;
+ b->y1 = b->oy;
+ b->x2 = b->ox+b->bWidth;
+ b->y2 = b->oy+b->bHeight;
+ b->dx = b->ox+b->bWidth;
+ b->dy = b->oy-b->bHeight;
+ b->transRegion->extents.x1 = b->ox;
+ b->transRegion->extents.y1 = b->dy;
+ b->transRegion->extents.x2 = b->dx;
+ b->transRegion->extents.y2 = b->oy;
break;
case SW:
// Place the button in the lower left corner
- b->x1 = 0;
- b->y1 = fcScreenHeight - b->bHeight;
- b->x2 = b->x1+b->bWidth;
- b->y2 = b->y1+b->bHeight;
+ b->ox = 0;
+ b->oy = fcScreenHeight - b->bHeight;
+ b->x1 = b->ox;
+ b->y1 = b->oy;
+ b->x2 = b->ox+b->bWidth;
+ b->y2 = b->oy+b->bHeight;
+ b->dx = b->ox-b->bWidth;
+ b->dy = b->oy+b->bHeight;
+ b->transRegion->extents.x1 = b->dx;
+ b->transRegion->extents.y1 = b->oy;
+ b->transRegion->extents.x2 = b->ox;
+ b->transRegion->extents.y2 = b->dy;
break;
case SE:
// Place the button in the lower right corner
- b->x1 = fcScreenWidth - b->bWidth;
- b->y1 = fcScreenHeight - b->bHeight;
- b->x2 = b->x1+b->bWidth;
- b->y2 = b->y1+b->bHeight;
+ b->ox = fcScreenWidth - b->bWidth;
+ b->oy = fcScreenHeight - b->bHeight;
+ b->x1 = b->ox;
+ b->y1 = b->oy;
+ b->x2 = b->ox+b->bWidth;
+ b->y2 = b->oy+b->bHeight;
+ b->dx = b->ox+b->bWidth;
+ b->dy = b->oy+b->bHeight;
+ b->transRegion->extents.x1 = b->ox;
+ b->transRegion->extents.y1 = b->oy;
+ b->transRegion->extents.x2 = b->dx;
+ b->transRegion->extents.y2 = b->dy;
break;
default:
// Place button centered across screen width, at bottom of the screen
- b->x1 = (int)(fcScreenWidth/2) - (int)(b->bWidth/2);
- b->y1 = fcScreenHeight - b->bHeight;
- b->x2 = b->x1+b->bWidth;
- b->y2 = b->y1+b->bHeight;
+ b->ox = (int)(fcScreenWidth/2) - (int)(b->bWidth/2);
+ b->oy = fcScreenHeight - b->bHeight;
+ b->x1 = b->ox;
+ b->y1 = b->oy;
+ b->x2 = b->ox+b->bWidth;
+ b->y2 = b->oy+b->bHeight;
+ b->dx = b->ox;
+ b->dy = b->oy+b->bHeight;
+ b->transRegion->extents.x1 = b->ox;
+ b->transRegion->extents.y1 = b->oy;
+ b->transRegion->extents.x2 = b->dx;
+ b->transRegion->extents.y2 = b->dy;
break;
}
+ b->bRegion = XCreateRegion();
+ b->bRegion->extents.x1 = b->x1;
+ b->bRegion->extents.y1 = b->y1;
+ b->bRegion->extents.x2 = b->x2;
+ b->bRegion->extents.y2 = b->y2;
+ b->bRegion->rects = &b->bRegion->extents;
+ b->bRegion->numRects = 1;
+
}
// Utility function to set the image filename where needed
@@ -386,15 +459,18 @@ static FCButton *fcNewButton (int g, CompScreen *s)
// Set up the final render dimensions of the button
fcResizeButton (b, fcButtonWidth, fcButtonHeight);
- compLogMessage(s->display, "fc", CompLogLevelInfo,
+ compLogMessage(s->display, "fc", CompLogLevelDebug,
"Button filename: %s",b->filename);
- compLogMessage(s->display, "fc", CompLogLevelInfo,
+ compLogMessage(s->display, "fc", CompLogLevelDebug,
"Button dimensions: %dx%d",b->bWidth,b->bHeight);
- compLogMessage(s->display, "fc", CompLogLevelInfo,
- "Button location:");
- compLogMessage(s->display, "fc", CompLogLevelInfo,
- "\n\t(%4d,%d)\t(%4d,%d)\n\t(%4d,%d)\t(%4d,%d)",
- b->x1,b->y1,b->x2,b->y1,b->x1,b->y2,b->x2,b->y2);
+ compLogMessage(s->display, "fc", CompLogLevelDebug,
+ "Button location: (%4d,%d)\t(%4d,%d)",b->x1,b->y1,b->x2,b->y1);
+ compLogMessage(s->display, "fc", CompLogLevelDebug,
+ " (%4d,%d)\t(%4d,%d)",b->x1,b->y2,b->x2,b->y2);
+ compLogMessage(s->display, "fc", CompLogLevelDebug,
+ "Button translation region: (%4d,%d)\t(%4d,%d)",
+ b->transRegion->extents.x1,b->transRegion->extents.y1,
+ b->transRegion->extents.x2,b->transRegion->extents.y2);
// Set the functions to call when the button is pressed/released
b->press = fcButtonPressed;
@@ -433,95 +509,131 @@ static void drawCorner (CompScreen *s, int g)
}
}
-static void fcShowHideCornersStep(int direction)
+static float fcOffsetFromTime(int period, // length of full transition time
+ int slice, // amount of time already passed
+ int distance, // distance btwn start/end position
+ int direction)// sign applied to result for
+ // "direction" of change (+/-)
{
- int d = direction;
+ float result=0;
+ float d=0;
- if (d >= 0)
- d = 1;
+ if (period==0)
+ return 0;
else
- d = -1;
-
- fcRelocateButton(corners[NW].button,
- corners[NW].button->x1-(d*corners[NW].button->xd),
- corners[NW].button->y1-(d*corners[NW].button->yd));
- fcRelocateButton(corners[NE].button,
- corners[NE].button->x1+(d*corners[NE].button->xd),
- corners[NE].button->y1-(d*corners[NE].button->yd));
- fcRelocateButton(corners[SW].button,
- corners[SW].button->x1-(d*corners[SW].button->xd),
- corners[SW].button->y1+(d*corners[SW].button->yd));
- fcRelocateButton(corners[SE].button,
- corners[SE].button->x1+(d*corners[SE].button->xd),
- corners[SE].button->y1+(d*corners[SE].button->yd));
+ {
+ // ====================================================================
+ // TODO: Fix offset calculation...it's getting skewed too fast
+ // ====================================================================
+ d=(direction >= 0)?1.0:-1.0;
+ result = (float)(d*((float)distance*((float)slice/(float)period)));
+ return result;
+ }
}
-static Bool fcShowHideCorners (void *closure)
+static void fcShowHideCornersFinal(int dir)
{
- CompScreen *s = (CompScreen *)closure;
- FC_SCREEN(s);
+ int i;
+
+ for (i=0;i<4;i++)
+ {
+ if (dir >= 0) // Hiding...
+ fcRelocateButton(corners[i].button,
+ corners[i].button->dx,
+ corners[i].button->dy);
+ else // Showing...
+ fcRelocateButton(corners[i].button,
+ corners[i].button->ox,
+ corners[i].button->oy);
+ }
+}
+
+static void fcShowHideCornersStep(int offset)
+{
+ FCButton *b;
+
+ b=corners[NW].button;
+ fcRelocateButton(b, b->x1-offset, b->y1-offset);
+ b=corners[NE].button;
+ fcRelocateButton(b, b->x1+offset, b->y1-offset);
+ b=corners[SW].button;
+ fcRelocateButton(b, b->x1-offset, b->y1+offset);
+ b=corners[SE].button;
+ fcRelocateButton(b, b->x1+offset, b->y1+offset);
+}
+
+// Called after all plugins have completed their PaintOutput methods
+static void fcPreparePaintScreen (CompScreen *s, int ms)
+{
+ FC_SCREEN (s);
+
+ int timeSoFar;
+ int slice;
+ float offset;
+ struct timeval now;
// We're hiding the corner buttons
if (fc_screen->hiding)
{
- if (fc_screen->lastStep < fc_screen->maxStep)
+ gettimeofday(&now,0);
+ timeSoFar=(int)DIFFTIMEMS(&now,&fc_screen->startTime);
+ if (timeSoFar < fc_screen->transTime) // more time left to draw
{
// Take next step in hide render annimation
- fcShowHideCornersStep(1);
- fc_screen->lastStep++;
- damageScreen(s);
- return TRUE;
+ slice = (int)DIFFTIMEMS(&now,&fc_screen->lastTime);
+ offset =
fcOffsetFromTime(fc_screen->transTime,slice,fcButtonWidth,1);
+ // Take a step if the offset is >= 1. Pixel coordinates can only
+ // change by whole integer values, so we'll wait until enough
+ // time has passed so we can move the button in a meaningful way
+ if (offset >= 0.5)
+ {
+ fcShowHideCornersStep(ROUND(offset));
+ fc_screen->lastTime = now;
+ }
}
- else
+ else // no more time left, move to final location
{
_______________________________________________
Commits mailing list
[email protected]
https://www.moblin.org/mailman/listinfo/commits