This email list is read-only. Emails sent to this list will be discarded
----------------------------------
four-corners/fc.c | 363 +++++++++++++++++++++++++++---------------------
four-corners/fc.xml.in | 86 +++++++-----
2 files changed, 261 insertions(+), 188 deletions(-)
New commits:
commit 172ebe0f98f539228e981d88785f9ebe8ed944b4
Author: Shane Bryan <[EMAIL PROTECTED]>
Date: Thu Aug 7 19:04:47 2008 -0700
- Fixed bug where hidden buttons still get press events and start apps
- Added option to each corner to enable or disable it
- replaced TABs with spaces :(
Signed-off-by: Shane Bryan <[EMAIL PROTECTED]>
Diff in this email is a maximum of 400 lines.
diff --git a/four-corners/fc.c b/four-corners/fc.c
index fabdfde..9594be0 100644
--- a/four-corners/fc.c
+++ b/four-corners/fc.c
@@ -47,6 +47,7 @@ typedef struct _FCButton {
void (*press)(int g);
void (*release)(CompScreen *s, int g);
+ Bool enabled; // flag to determine if this button is to be visible
Bool pressed; // flag to tell us if the button press state
enum Gravity gravity; // which corner does this button live in
char *filename; // full path to image file for button
@@ -76,14 +77,14 @@ typedef struct _FCButton {
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
+ // - assumes scale of 1.0 when fully shown
} FCButton, *pFCButton;
typedef struct _FCCorner {
char *name;
char *filename;
FCButton *button;
- CompWindow *window;
+ CompWindow *window;
} FCCorner;
FCCorner corners[4] = {
@@ -94,12 +95,12 @@ FCCorner corners[4] = {
};
typedef struct _FCDisplay {
- int screenPrivateIndex;
- HandleEventProc handleEvent;
- CompWindow *utah_window;
- CompWindow *arizona_window;
- CompWindow *newmexico_window;
- CompWindow *colorado_window;
+ int screenPrivateIndex;
+ HandleEventProc handleEvent;
+ CompWindow *utah_window;
+ CompWindow *arizona_window;
+ CompWindow *newmexico_window;
+ CompWindow *colorado_window;
} FCDisplay;
typedef struct _FCScreen {
@@ -108,7 +109,7 @@ typedef struct _FCScreen {
DonePaintScreenProc donePaintScreen;
int grab;
- int windowPrivateIndex;
+ int windowPrivateIndex;
Bool hiding;
Bool showing;
int transTime;
@@ -119,23 +120,23 @@ typedef struct _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 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) \
+#define GET_FC_DISPLAY(d) \
((FCDisplay *) (d)->base.privates[displayPrivateIndex].ptr)
-#define FC_DISPLAY(d) \
+#define FC_DISPLAY(d) \
FCDisplay *fc_display = GET_FC_DISPLAY (d)
-#define GET_FC_SCREEN(s, pd) \
+#define GET_FC_SCREEN(s, pd) \
((FCScreen *) (s)->base.privates[(pd)->screenPrivateIndex].ptr)
-#define FC_SCREEN(s) \
+#define FC_SCREEN(s) \
FCScreen *fc_screen = GET_FC_SCREEN (s, GET_FC_DISPLAY (s->display))
static Bool fcUpdateWindowMatch (CompWindow *w)
@@ -201,30 +202,30 @@ static void fcButtonReleased(CompScreen *s, int g)
// TODO: When we have visual "press" cueing, need to uncue here
// =============================================================
// corners[g].button->action();
- if (corners[g].window)
- {
- // Raise the window
- raiseWindow(corners[g].window);
- }
- else
- {
- // Execute the command
- switch (g)
- {
- case NW:
- runCommand(s,fcGetUtahAction(s));
- break;
- case NE:
- runCommand(s,fcGetColoradoAction(s));
- break;
- case SW:
- runCommand(s,fcGetArizonaAction(s));
- break;
- case SE:
- runCommand(s,fcGetNewmexicoAction(s));
- break;
- }
- }
+ if (corners[g].window)
+ {
+ // Raise the window
+ raiseWindow(corners[g].window);
+ }
+ else
+ {
+ // Execute the command
+ switch (g)
+ {
+ case NW:
+ runCommand(s,fcGetUtahAction(s));
+ break;
+ case NE:
+ runCommand(s,fcGetColoradoAction(s));
+ break;
+ case SW:
+ runCommand(s,fcGetArizonaAction(s));
+ break;
+ case SE:
+ runCommand(s,fcGetNewmexicoAction(s));
+ break;
+ }
+ }
}
else
// This button was not originally pressed, but one of the other was
@@ -242,11 +243,16 @@ static Bool fcPointInButton (int x, int y, int *g)
for (i=0; i<4; i++)
{
- if (XPointInRegion(corners[i].button->bRegion,x,y))
+ // only test on enabled buttons
+ if (corners[i].button->enabled)
{
- *g = FCGravity[i];
- hit = TRUE;
- break;
+ if (corners[i].button->enabled &&
+ XPointInRegion(corners[i].button->bRegion,x,y))
+ {
+ *g = FCGravity[i];
+ hit = TRUE;
+ break;
+ }
}
}
@@ -258,6 +264,10 @@ static Bool fcRegionInButton (Region r, int g)
{
int overlap = RectangleOut;
+ // if the button is not enabled, nothing to test...
+ if (!corners[g].button->enabled)
+ return FALSE;
+
overlap = XRectInRegion(r, corners[g].button->x1,
corners[g].button->y1,
corners[g].button->bWidth,
@@ -284,6 +294,18 @@ static void fcRelocateButton (FCButton *b, int newX, int
newY)
b->x2 = b->x1+b->bWidth;
b->y1 = newY;
b->y2 = b->y1+b->bHeight;
+
+ // ===========================================================
+ // TODO: I should use regions throughout the code rather than
+ // both regions and independant coordinates...
+ // ===========================================================
+
+ // update the region to match so button press/release events
+ // will only match the ACTUALL button location
+ b->bRegion->extents.x1 = b->x1;
+ b->bRegion->extents.y1 = b->y1;
+ b->bRegion->extents.x2 = b->x2;
+ b->bRegion->extents.y2 = b->y2;
}
}
@@ -433,9 +455,9 @@ static Bool fcButtonImageToTexture (CompScreen *s, FCButton
*b)
// can not be parsed/loaded.
if (!readImageToTexture(s, &b->ct, b->filename, &b->tWidth, &b->tHeight))
{
- compLogMessage(s->display, "fc", CompLogLevelError,
+ compLogMessage(s->display, "fc", CompLogLevelError,
"Failed to create texture from %s",b->filename);
- return FALSE;
+ return FALSE;
}
return TRUE;
@@ -451,11 +473,11 @@ static FCButton *fcNewButton (int g, CompScreen *s)
"Creating Button: %s",corner_name[g]);
FCButton *b = malloc(sizeof(FCButton));
- if (!b) {
- compLogMessage(s->display, "fc", CompLogLevelError,
+ if (!b) {
+ compLogMessage(s->display, "fc", CompLogLevelError,
"Cannot create new button: Out of memory!");
- return NULL;
- }
+ return NULL;
+ }
memset(b, 0, sizeof(FCButton));
@@ -476,7 +498,7 @@ static FCButton *fcNewButton (int g, CompScreen *s)
free (b->filename);
memset(b, 0, sizeof(FCButton));
free (b);
- return NULL;
+ return NULL;
}
// Set up the final render dimensions of the button
@@ -508,6 +530,11 @@ static void drawCorner (CompScreen *s, int g)
{
FCButton *b = corners[g].button;
+ if (!b->enabled)
+ {
+ return;
+ }
+
if (b != NULL)
{
// Bind to button texture (uses compiz methods)
@@ -573,7 +600,7 @@ static void fcShowHideCornersFinal(int dir)
static void fcShowHideCornersStep(int offset)
{
- FCButton *b;
+ FCButton *b;
b=corners[NW].button;
fcRelocateButton(b, b->x1-offset, b->y1-offset);
@@ -611,7 +638,7 @@ static void fcPreparePaintScreen (CompScreen *s, int ms)
if (offset >= 0.5)
{
fcShowHideCornersStep(ROUND(offset));
- fc_screen->lastTime = now;
+ fc_screen->lastTime = now;
}
}
else // no more time left, move to final location
@@ -640,7 +667,7 @@ static void fcPreparePaintScreen (CompScreen *s, int ms)
if (offset <= -0.5)
{
fcShowHideCornersStep(ROUND(offset));
- fc_screen->lastTime = now;
+ fc_screen->lastTime = now;
}
}
else
@@ -730,8 +757,8 @@ static void fcDonePaintScreen (CompScreen *s)
{
FC_SCREEN (s);
- if (fc_screen->showing || fc_screen->hiding)
- damageScreen(s);
+ if (fc_screen->showing || fc_screen->hiding)
+ damageScreen(s);
UNWRAP (fc_screen, s, donePaintScreen);
(*s->donePaintScreen) (s);
@@ -744,7 +771,7 @@ static void fcHandleEvent (CompDisplay *d, XEvent *event)
CompScreen *s = NULL;
int g = -1;
- FC_DISPLAY(d);
+ FC_DISPLAY(d);
if (event->xany.send_event == True)
goto end;
@@ -899,41 +926,57 @@ static void fcScreenOptionChanged (CompScreen *s,
CompOption *opt,
FC_SCREEN(s);
switch(num) {
+ case FcScreenOptionUtahEnable:
+ corners[NW].button->enabled=fcGetUtahEnable(s);
+ redraw = TRUE;
+ break;
+ case FcScreenOptionColoradoEnable:
+ corners[NE].button->enabled=fcGetColoradoEnable(s);
+ redraw = TRUE;
+ break;
+ case FcScreenOptionArizonaEnable:
+ corners[SW].button->enabled=fcGetArizonaEnable(s);
+ redraw = TRUE;
+ break;
+ case FcScreenOptionNewmexicoEnable:
+ corners[SE].button->enabled=fcGetNewmexicoEnable(s);
+ redraw = TRUE;
+ break;
case FcScreenOptionButtonSize:
// for now, we are assuming square buttons
fcButtonWidth = fcButtonHeight = fcGetButtonSize(s);
// since we've had a request to change size, re-calc all buttons
- for (i=0;i<4;i++)
- {
- fcResizeButton (corners[i].button, fcButtonWidth,
fcButtonHeight);
- }
+ for (i=0;i<4;i++)
+ {
+ fcResizeButton (corners[i].button, fcButtonWidth, fcButtonHeight);
+ }
redraw = TRUE;
break;
case FcScreenOptionAnimationLength:
fc_screen->transTime = fcGetAnimationLength(s);
break;
- case FcScreenOptionVisibleOpacity:
- for (i=0;i<4;i++)
- {
- // rebase the desired opacity for full visible button
-
corners[i].button->visibleOpacity=fcGetVisibleOpacity(s);
- }
+ case FcScreenOptionVisibleOpacity:
+ for (i=0;i<4;i++)
+ {
+ // rebase the desired opacity for full visible button
+ corners[i].button->visibleOpacity=fcGetVisibleOpacity(s);
+ }
redraw = TRUE;
break;
- case FcScreenOptionHiddenOpacity:
- for (i=0;i<4;i++)
- {
- // rebase the desired opacity for full visible button
- corners[i].button->hiddenOpacity=fcGetHiddenOpacity(s);
- }
+ case FcScreenOptionHiddenOpacity:
+ for (i=0;i<4;i++)
+ {
+ // rebase the desired opacity for full visible button
+ corners[i].button->hiddenOpacity=fcGetHiddenOpacity(s);
+ }
break;
- case FcScreenOptionHiddenScale:
- for (i=0;i<4;i++)
- {
- // rebase the desired opacity for full visible button
- corners[i].button->hiddenScale=fcGetHiddenScale(s);
- }
+ case FcScreenOptionHiddenScale:
+ for (i=0;i<4;i++)
+ {
+ // rebase the desired opacity for full visible button
+ corners[i].button->hiddenScale=fcGetHiddenScale(s);
+ }
break;
case FcScreenOptionUtahAction:
break;
@@ -948,9 +991,9 @@ static void fcScreenOptionChanged (CompScreen *s,
CompOption *opt,
case FcScreenOptionColoradoMatch:
case FcScreenOptionArizonaMatch:
case FcScreenOptionNewmexicoMatch:
- for(w = s->windows; w; w = w->next)
- fcUpdateWindowMatch(w);
- break;
+ for(w = s->windows; w; w = w->next)
+ fcUpdateWindowMatch(w);
+ break;
// ================================================================
// TODO: For the following 4 options, if the file name has been
@@ -1017,12 +1060,16 @@ static Bool fcInitCorners (CompScreen *s)
if (!corners[NW].button)
corners[NW].button = fcNewButton(NW, s);
+ corners[NW].button->enabled = fcGetUtahEnable(s);
if (!corners[NE].button)
corners[NE].button = fcNewButton(NE, s);
+ corners[NE].button->enabled = fcGetColoradoEnable(s);
if (!corners[SW].button)
corners[SW].button = fcNewButton(SW, s);
+ corners[SW].button->enabled = fcGetArizonaEnable(s);
if (!corners[SE].button)
corners[SE].button = fcNewButton(SE, s);
+ corners[SE].button->enabled = fcGetNewmexicoEnable(s);
_______________________________________________
Commits mailing list
[email protected]
https://www.moblin.org/mailman/listinfo/commits