summaryrefslogtreecommitdiff
path: root/beryl-plugins/src/trailfocus2.c
diff options
context:
space:
mode:
authorkristian <kristian@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2007-01-17 17:11:26 +0000
committerkristian <kristian@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2007-01-17 17:11:26 +0000
commitcda5d80a7de4f166cdd6d872b7c1d5ed2ef2180a (patch)
tree6921ed77053ef435bf52d9b6b44fabcf8b6f4d94 /beryl-plugins/src/trailfocus2.c
parent1f583ea3f3a682189b6be77081c3b1717d064a9b (diff)
downloadmarex-dev-cda5d80a7de4f166cdd6d872b7c1d5ed2ef2180a.tar.gz
marex-dev-cda5d80a7de4f166cdd6d872b7c1d5ed2ef2180a.tar.bz2
trailfocus2.c: Add a range-setup, still bugged in recalculate_attributes() for now...
git-svn-id: file:///beryl/trunk@2785 d7aaf104-2d23-0410-ae22-9d23157bf5a3
Diffstat (limited to 'beryl-plugins/src/trailfocus2.c')
-rw-r--r--beryl-plugins/src/trailfocus2.c59
1 files changed, 44 insertions, 15 deletions
diff --git a/beryl-plugins/src/trailfocus2.c b/beryl-plugins/src/trailfocus2.c
index ebbbb09..946abda 100644
--- a/beryl-plugins/src/trailfocus2.c
+++ b/beryl-plugins/src/trailfocus2.c
@@ -63,6 +63,7 @@ typedef enum _TfOpt
SOPT_MIN_OPACITY,
SOPT_MIN_BRIGHTNESS,
SOPT_MIN_SATURATION,
+ SOPT_WINDOWS_START,
SOPT_WINDOWS,
SOPT_WINDOW_TYPE,
SOPT_IGNORE_SKIPTASKBAR,
@@ -312,29 +313,36 @@ static void recalculate_attributes(TrailfocusScreen * ts)
{
TfAttrib tmp, min, max;
int i;
-
+ int start;
+ start = ts->opt[SOPT_WINDOWS_START].value.i;
ts->win_max = ts->opt[SOPT_WINDOWS].value.i;
+ if (start > ts->win_max+1) {
+ fprintf(stderr, "trailfocus: WARNING: Attempting to define start higher than max windows.\n");
+ start = ts->win_max;
+ }
+
min.opacity = ts->opt[SOPT_MIN_OPACITY].value.i * OPAQUE / 100;
min.brightness = ts->opt[SOPT_MIN_BRIGHTNESS].value.i * OPAQUE / 100;
min.saturation = ts->opt[SOPT_MIN_SATURATION].value.i * OPAQUE / 100;
max.opacity = ts->opt[SOPT_MAX_OPACITY].value.i * OPAQUE / 100;
max.brightness = ts->opt[SOPT_MAX_BRIGHTNESS].value.i * OPAQUE / 100;
max.saturation = ts->opt[SOPT_MAX_SATURATION].value.i * OPAQUE / 100;
-
- ts->win = realloc(ts->win, sizeof(Window) * (ts->win_max + 1));
- ts->inc = realloc(ts->inc, sizeof(TfAttrib) * (ts->win_max + 1));
- tmp.opacity = (max.opacity - min.opacity) / ts->win_max;
- tmp.brightness = (max.brightness - min.brightness) / ts->win_max;
- tmp.saturation = (max.saturation - min.saturation) / ts->win_max;
-
- for (i = 0; i < ts->win_max; i++)
+ ts->win = realloc(ts->win, sizeof(Window) * (ts->win_max + 2));
+ ts->inc = realloc(ts->inc, sizeof(TfAttrib) * (ts->win_max + 2));
+ tmp.opacity = (max.opacity - min.opacity) / ((ts->win_max - start) + 1);
+ tmp.brightness = (max.brightness - min.brightness) / ((ts->win_max - start) +1);
+ tmp.saturation = (max.saturation - min.saturation) / ((ts->win_max - start) +1);
+ for (i = 0; i < start-1; i++ )
+ ts->inc[i] = max;
+
+ for (i = 0; i+start <= ts->win_max; i++)
{
- ts->inc[i].opacity = max.opacity - (tmp.opacity * i);
- ts->inc[i].brightness = max.brightness - (tmp.brightness * i);
- ts->inc[i].saturation = max.saturation - (tmp.saturation * i);
- ts->win[i] = 0;
+ ts->inc[i+start].opacity = max.opacity - (tmp.opacity * (i+1));
+ ts->inc[i+start].brightness = max.brightness - (tmp.brightness * (1+i));
+ ts->inc[i+start].saturation = max.saturation - (tmp.saturation * (1+i));
+ ts->win[i+start] = 0;
}
- ts->inc[i] = min;
+// ts->inc[i+start] = min;
}
/* Unlike the traditional setScreenOptions, we return on failure in the
@@ -360,6 +368,7 @@ static Bool trailfocusSetScreenOptions(CompScreen * screen, char *name,
case SOPT_MIN_BRIGHTNESS:
case SOPT_MIN_SATURATION:
case SOPT_WINDOWS:
+ case SOPT_WINDOWS_START:
if (!compSetIntOption(o, value))
return FALSE;
recalculate_attributes(ts);
@@ -393,6 +402,10 @@ static void trailfocusFiniScreen(CompPlugin * p, CompScreen * s)
{
TRAILFOCUS_SCREEN(s);
bail_out_tf(s);
+ if (ts->win)
+ free(ts->win);
+ if (ts->inc)
+ free(ts->inc);
if (ts->opt[SOPT_WINDOW_TYPE].value.list.value)
free(ts->opt[SOPT_WINDOW_TYPE].value.list.value);
free(ts);
@@ -503,7 +516,7 @@ static void trailfocusScreenInitOptions(TrailfocusScreen * ts)
N_
("Number of windows trailfocus will keep track of. Windows had focus "
" this amount of windows ago or more, will be considered completly"
- " unfocused.");
+ " unfocused. ");
o->type = CompOptionTypeInt;
o->value.i = 5;
o->rest.i.min = 1;
@@ -511,6 +524,22 @@ static void trailfocusScreenInitOptions(TrailfocusScreen * ts)
o->advanced = False;
ts->win_max = 5;
+ o = &ts->opt[SOPT_WINDOWS_START];
+ o->name = "windows_start";
+ o->group = N_("Behaviour");
+ o->subGroup = N_("");
+ o->displayHints = "";
+ o->shortDesc = N_("What window to start fading");
+ o->longDesc =
+ N_
+ ("This defines when trailfocus will start windows, this lets you set up "
+ "trailfocus to treat the N first windows as fully focused.");
+ o->type = CompOptionTypeInt;
+ o->value.i = 2;
+ o->rest.i.min = 1;
+ o->rest.i.max = 20;
+ o->advanced = False;
+
o = &ts->opt[SOPT_WINDOW_TYPE];
o->name = "window_types";