summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--beryl-plugins/src/Makefile.am8
-rw-r--r--beryl-plugins/src/trailfocus.c818
-rw-r--r--beryl-plugins/src/trailfocus2.c716
-rw-r--r--beryl-settings/images/Makefile.am2
-rw-r--r--beryl-settings/images/beryl-settings-section-trailfocus2.svg (renamed from beryl-settings/images/beryl-settings-section-trailfocus.svg)0
5 files changed, 721 insertions, 823 deletions
diff --git a/beryl-plugins/src/Makefile.am b/beryl-plugins/src/Makefile.am
index da936b1..0e67344 100644
--- a/beryl-plugins/src/Makefile.am
+++ b/beryl-plugins/src/Makefile.am
@@ -67,9 +67,9 @@ libshowdesktop_la_LDFLAGS = $(PFLAGS)
libshowdesktop_la_LIBADD = @BERYL_LIBS@ @BERYLSETTINGS_LIBS@
libshowdesktop_la_SOURCES = showdesktop.c
-libtrailfocus_la_LDFLAGS = $(PFLAGS)
-libtrailfocus_la_LIBADD = @BERYL_LIBS@ @BERYLSETTINGS_LIBS@
-libtrailfocus_la_SOURCES = trailfocus.c
+libtrailfocus2_la_LDFLAGS = $(PFLAGS)
+libtrailfocus2_la_LIBADD = @BERYL_LIBS@ @BERYLSETTINGS_LIBS@
+libtrailfocus2_la_SOURCES = trailfocus2.c
libfade_la_LDFLAGS = $(PFLAGS)
libfade_la_LIBADD = @BERYL_LIBS@ @BERYLSETTINGS_LIBS@
@@ -181,7 +181,7 @@ module_LTLIBRARIES = \
libplace.la \
libswitcher.la \
libwater.la \
- libtrailfocus.la \
+ libtrailfocus2.la \
libneg.la \
libput.la \
libshowdesktop.la \
diff --git a/beryl-plugins/src/trailfocus.c b/beryl-plugins/src/trailfocus.c
deleted file mode 100644
index 2cca9dd..0000000
--- a/beryl-plugins/src/trailfocus.c
+++ /dev/null
@@ -1,818 +0,0 @@
-/*
- * Copyright (C) 2006 Fran\xc3\xa7ois Ingelrest <Athropos@gmail.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-/**
- *
- * trailfocus.c: rewrite
- *
- * Author: Dennis Kasprzyk
- * E-Mail: onestone@beryl-project.org
- *
- * ---------------------------------------------
- *
- * trailfocus.c:
- * author: casey langen, 2006
- * version: 0.1.2
- * purpose: leave a "trail" of focused windows
- *
- * ---------------------------------------------
- *
- * based on...
- *
- * trailFocus.c v0.03
- *
- * Author: Fran\xc3\xa7ois Ingelrest
- * E-Mail: Athropos@gmail.com
- *
- **/
-
-#include <beryl.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-
-
-/* option identifiers ---------------------------------------------------- */
-
-
-#define TRAILFOCUS_SCREEN_OPTION_MINIMUM_OPACITY_LEVEL 0
-#define TRAILFOCUS_SCREEN_OPTION_MAXIMUM_OPACITY_LEVEL 1
-#define TRAILFOCUS_SCREEN_OPTION_MINIMUM_SATURATION_LEVEL 2
-#define TRAILFOCUS_SCREEN_OPTION_MAXIMUM_SATURATION_LEVEL 3
-#define TRAILFOCUS_SCREEN_OPTION_MINIMUM_BRIGHTNESS_LEVEL 4
-#define TRAILFOCUS_SCREEN_OPTION_MAXIMUM_BRIGHTNESS_LEVEL 5
-#define TRAILFOCUS_SCREEN_OPTION_MAXIMUM_TRAIL_COUNT 6
-#define TRAILFOCUS_SCREEN_OPTION_WINDOW_TYPE 7
-#define TRAILFOCUS_SCREEN_OPTION_IGNORE_SKIPTASKBAR 8
-#define TRAILFOCUS_SCREEN_OPTION_IGNORE_SKIPPAGER 9
-#define TRAILFOCUS_SCREEN_OPTION_DISABLE_ON_SCREENGRAB_OF 10
-#define TRAILFOCUS_SCREEN_OPTION_EXCLUDE_LIST 11
-#define TRAILFOCUS_SCREEN_OPTION_NUM 12
-
-#define TRAILFOCUS_SCREEN_OPTION_IGNORE_SKIPTASKBAR_DEFAULT TRUE
-#define TRAILFOCUS_SCREEN_OPTION_IGNORE_SKIPPAGER_DEFAULT TRUE
-
-static char *DefaultWinType[] = {
- N_("Normal"),
-};
-
-static char *DisableOnScreengrabDefault[] = { "switcher", "scale" };
-
-/* macros --------------------------------------------------------------- */
-
-
-#define GET_TRAILFOCUS_DISPLAY(display) \
- ((TrailFocusDisplay*)display->privates[mDisplayPrivateIndex].ptr)
-
-#define GET_TRAILFOCUS_SCREEN(screen) \
- ((TrailFocusScreen*)screen->privates[GET_TRAILFOCUS_DISPLAY(screen->display)->screenPrivateIndex].ptr)
-
-#define GET_TRAILFOCUS_WINDOW(w, tfs) \
- ((TrailFocusWindow *) (w)->privates[(tfs)->windowPrivateIndex].ptr)
-
-#define NUM_OPTIONS(screen) (sizeof((screen)->opt) / sizeof(CompOption))
-
-#define LIST_SIZE(l) (sizeof (l) / sizeof (l[0]))
-
-/* structs -------------------------------------------------------------- */
-
-
-typedef struct _TrailFocusDisplay
-{
- int screenPrivateIndex;
-} TrailFocusDisplay;
-
-typedef struct _TrailFocusScreen
-{
- int windowPrivateIndex;
- int wmask; // Which kind of windows are we looking at?
-
- int minSaturationLevel;
- int minBrightnessLevel;
- int minOpacityLevel;
- int maxTrailCount;
-
- int maxSaturationLevel;
- int maxBrightnessLevel;
- int maxOpacityLevel;
-
- PaintWindowProc paintWindow;
- PreparePaintScreenProc preparePaintScreen;
-
- CompOption opt[TRAILFOCUS_SCREEN_OPTION_NUM];
-} TrailFocusScreen;
-
-typedef struct _TrailFocusWindow
-{
- Bool isActive;
- Bool isUpdated;
- int position;
- GLushort saturation;
- GLushort brightness;
- GLushort opacity;
-} TrailFocusWindow;
-
-
-/* locals ---------------------------------------------------------------- */
-
-static int mDisplayPrivateIndex;
-
-/* Beryl prototypes ----------------------------------------------------- */
-
-
-static Bool trailFocusInit(CompPlugin * p);
-static void trailFocusFini(CompPlugin * p);
-static Bool trailFocusInitDisplay(CompPlugin * p, CompDisplay * d);
-static void trailFocusFiniDisplay(CompPlugin * p, CompDisplay * d);
-static Bool trailFocusInitScreen(CompPlugin * p, CompScreen * s);
-static void trailFocusFiniScreen(CompPlugin * p, CompScreen * s);
-static Bool trailFocusInitWindow(CompPlugin * p, CompWindow * w);
-static void trailFocusFiniWindow(CompPlugin * p, CompWindow * w);
-static Bool trailFocusSetScreenOption(CompScreen * screen, char *name,
- CompOptionValue * value);
-static CompOption *trailFocusGetScreenOptions(CompScreen * screen,
- int *count);
-static Bool trailFocusPaintWindow(CompWindow * w,
- const WindowPaintAttrib * attrib,
- Region region, unsigned int mask);
-static void trailFocusPreparePaintScreen(CompScreen * s, int ms);
-
-/* Beryl requests this table in the entry point */
-static CompPluginVTable trailFocusVTable = {
- "trailfocus",
- N_("Trailfocus"),
- N_("Window focus leaves a trail"),
- trailFocusInit,
- trailFocusFini,
- trailFocusInitDisplay,
- trailFocusFiniDisplay,
- trailFocusInitScreen,
- trailFocusFiniScreen,
- trailFocusInitWindow,
- trailFocusFiniWindow,
- 0, /* GetDisplayOptions */
- 0, /* SetDisplayOption */
- trailFocusGetScreenOptions,
- trailFocusSetScreenOption,
- NULL,
- 0,
- 0,
- 0,
- BERYL_ABI_INFO,
- "beryl-plugins",
- "effects",
- 0,
- 0,
- False,
-};
-
-
-/* entry point */
-CompPluginVTable *getCompPluginInfo(void)
-{
- return &trailFocusVTable;
-}
-
-/* plugin init */
-static Bool trailFocusInit(CompPlugin * p)
-{
- mDisplayPrivateIndex = allocateDisplayPrivateIndex();
- if (mDisplayPrivateIndex < 0)
- {
- return FALSE;
- }
-
- return TRUE;
-}
-
-/* plugin exit */
-static void trailFocusFini(CompPlugin * p)
-{
- if (mDisplayPrivateIndex >= 0)
- {
- freeDisplayPrivateIndex(mDisplayPrivateIndex);
- }
-}
-
-/* display init */
-static Bool trailFocusInitDisplay(CompPlugin * p, CompDisplay * d)
-{
- TrailFocusDisplay *tfd;
-
- tfd = malloc(sizeof(TrailFocusDisplay));
- if (!tfd)
- {
- return FALSE;
- }
-
- tfd->screenPrivateIndex = allocateScreenPrivateIndex(d);
- if (tfd->screenPrivateIndex < 0)
- {
- free(tfd);
- return FALSE;
- }
-
- d->privates[mDisplayPrivateIndex].ptr = tfd;
-
- return TRUE;
-}
-
-/* display exit */
-static void trailFocusFiniDisplay(CompPlugin * p, CompDisplay * d)
-{
- TrailFocusDisplay *tfd = GET_TRAILFOCUS_DISPLAY(d);
-
- freeScreenPrivateIndex(d, tfd->screenPrivateIndex);
-
- free(tfd);
-}
-static void trailFocusScreenInitOptions(TrailFocusScreen * tfs)
-{
- CompOption *o;
- int i;
-
- /* Options for this plugin */
- o = &tfs->opt[TRAILFOCUS_SCREEN_OPTION_MINIMUM_OPACITY_LEVEL];
- o->advanced = False;
- o->name = "minimum_window_opacity_level";
- o->group = N_("Appearance");
- o->subGroup = N_("Opacity");
- o->displayHints = "";
- o->shortDesc = N_("Opacity level of completely unfocused windows");
- o->longDesc = N_("Opacity level of completely unfocused windows");
- o->type = CompOptionTypeInt;
- o->value.i = 90;
- o->rest.i.min = 25;
- o->rest.i.max = 100;
- tfs->minOpacityLevel = 90;
-
- o = &tfs->opt[TRAILFOCUS_SCREEN_OPTION_MAXIMUM_OPACITY_LEVEL];
- o->advanced = False;
- o->name = "maximum_window_opacity_level";
- o->group = N_("Appearance");
- o->subGroup = N_("Opacity");
- o->displayHints = "";
- o->shortDesc = N_("Opacity level of completely focused windows");
- o->longDesc = N_("Opacity level of completely focused windows");
- o->type = CompOptionTypeInt;
- o->value.i = 100;
- o->rest.i.min = 25;
- o->rest.i.max = 100;
- tfs->maxOpacityLevel = 100;
-
- o = &tfs->opt[TRAILFOCUS_SCREEN_OPTION_MINIMUM_SATURATION_LEVEL];
- o->advanced = False;
- o->name = "minimum_window_saturation_level";
- o->group = N_("Appearance");
- o->subGroup = N_("Saturation");
- o->displayHints = "";
- o->shortDesc = N_("Saturation level of completely unfocused windows");
- o->longDesc = N_("Saturation level of completely unfocused windows");
- o->type = CompOptionTypeInt;
- o->value.i = 100;
- o->rest.i.min = 0;
- o->rest.i.max = 100;
- tfs->minSaturationLevel = 100;
-
- o = &tfs->opt[TRAILFOCUS_SCREEN_OPTION_MAXIMUM_SATURATION_LEVEL];
- o->advanced = False;
- o->name = "maximum_window_saturation_level";
- o->group = N_("Appearance");
- o->subGroup = N_("Saturation");
- o->displayHints = "";
- o->shortDesc = N_("Saturation level of completely focused windows");
- o->longDesc = N_("Saturation level of completely focused windows");
- o->type = CompOptionTypeInt;
- o->value.i = 100;
- o->rest.i.min = 0;
- o->rest.i.max = 100;
- tfs->maxSaturationLevel = 100;
-
- o = &tfs->opt[TRAILFOCUS_SCREEN_OPTION_MINIMUM_BRIGHTNESS_LEVEL];
- o->advanced = False;
- o->name = "minimum_window_brightness_level";
- o->group = N_("Appearance");
- o->subGroup = N_("Brightness");
- o->displayHints = "";
- o->shortDesc = N_("Brightness level of unfocused windows");
- o->longDesc = N_("Brightness level of unfocused windows");
- o->type = CompOptionTypeInt;
- o->value.i = 90;
- o->rest.i.min = 0;
- o->rest.i.max = 100;
- tfs->minBrightnessLevel = 90;
-
- o = &tfs->opt[TRAILFOCUS_SCREEN_OPTION_MAXIMUM_BRIGHTNESS_LEVEL];
- o->advanced = False;
- o->name = "maximum_window_brightness_level";
- o->group = N_("Appearance");
- o->subGroup = N_("Brightness");
- o->displayHints = "";
- o->shortDesc = N_("Brightness level of focused windows");
- o->longDesc = N_("Brightness level of focused windows");
- o->type = CompOptionTypeInt;
- o->value.i = 100;
- o->rest.i.min = 0;
- o->rest.i.max = 100;
- tfs->maxBrightnessLevel = 100;
-
-
- o = &tfs->opt[TRAILFOCUS_SCREEN_OPTION_MAXIMUM_TRAIL_COUNT];
- o->advanced = False;
- o->name = "maximum_trail_count";
- o->group = N_("Behaviour");
- o->subGroup = N_("");
- o->displayHints = "";
- o->shortDesc = N_("Number of recently used windows to keep track of");
- o->longDesc = N_("Number of recently used windows to keep track of");
- o->type = CompOptionTypeInt;
- o->value.i = 6;
- o->rest.i.min = 1;
- o->rest.i.max = 64;
- tfs->maxTrailCount = 6;
-
- o = &tfs->opt[TRAILFOCUS_SCREEN_OPTION_WINDOW_TYPE];
- o->advanced = False;
- o->name = "window_types";
- o->group = N_("Behaviour");
- o->subGroup = N_("");
- o->displayHints = "";
- o->shortDesc = N_("Trailfocus window types");
- o->longDesc = N_("Trailfocus window types");
- o->type = CompOptionTypeList;
- o->value.list.type = CompOptionTypeString;
- o->value.list.nValue = LIST_SIZE(DefaultWinType);
- o->value.list.value =
- malloc(sizeof(CompOptionValue) * LIST_SIZE(DefaultWinType));
- for (i = 0; i < LIST_SIZE(DefaultWinType); i++)
- o->value.list.value[i].s = strdup(DefaultWinType[i]);
- o->rest.s.string = (char **)windowTypeString;
- o->rest.s.nString = nWindowTypeString;
- tfs->wmask = compWindowTypeMaskFromStringList(&o->value);
-
- o = &tfs->opt[TRAILFOCUS_SCREEN_OPTION_IGNORE_SKIPTASKBAR];
- o->advanced = False;
- o->name = "ignore_skiptaskbar";
- o->group = N_("Behaviour");
- o->subGroup = N_("");
- o->displayHints = "";
- o->shortDesc = N_("Ignore \"SkipTaskbar\" Windows");
- o->longDesc = N_("Ignore \"SkipTaskbar\" Windows");
- o->type = CompOptionTypeBool;
- o->value.b = TRAILFOCUS_SCREEN_OPTION_IGNORE_SKIPTASKBAR_DEFAULT;
-
- o = &tfs->opt[TRAILFOCUS_SCREEN_OPTION_IGNORE_SKIPPAGER];
- o->advanced = False;
- o->name = "ignore_skippager";
- o->group = N_("Behaviour");
- o->subGroup = N_("");
- o->displayHints = "";
- o->shortDesc = N_("Ignore \"SkipPager\" Windows");
- o->longDesc = N_("Ignore \"SkipPager\" Windows");
- o->type = CompOptionTypeBool;
- o->value.b = TRAILFOCUS_SCREEN_OPTION_IGNORE_SKIPPAGER_DEFAULT;
-
- o = &tfs->opt[TRAILFOCUS_SCREEN_OPTION_DISABLE_ON_SCREENGRAB_OF];
- o->advanced = False;
- o->name = "disable_on_screengrab";
- o->group = N_("Behaviour");
- o->subGroup = N_("");
- o->displayHints = "";
- o->shortDesc = N_("Disable on screengrab of");
- o->longDesc = N_("Disable Trailfocus on screengrab of");
- o->type = CompOptionTypeList;
- o->value.list.type = CompOptionTypeString;
- o->value.list.nValue = LIST_SIZE(DisableOnScreengrabDefault);
- o->value.list.value =
- malloc(sizeof(CompOptionValue) *
- LIST_SIZE(DisableOnScreengrabDefault));
- o->rest.s.nString = 0;
- o->rest.s.string = NULL;
- for (i = 0; i < LIST_SIZE(DisableOnScreengrabDefault); i++)
- o->value.list.value[i].s = strdup(DisableOnScreengrabDefault[i]);
-
- o = &tfs->opt[TRAILFOCUS_SCREEN_OPTION_EXCLUDE_LIST];
- o->advanced = False;
- o->name = "exclude_list";
- o->group = N_("Behaviour");
- o->subGroup = N_("");
- o->displayHints = "";
- o->shortDesc = N_("WM_CLASS to exclude");
- o->longDesc = N_("Windows classes to exclude from trailfocusing");
- o->type = CompOptionTypeList;
- o->value.list.type = CompOptionTypeString;
- o->value.list.nValue = 0;
- o->value.list.value = 0;
- o->rest.s.string = 0;
- o->rest.s.nString = 0;
-}
-
-
-/* screen init */
-static Bool trailFocusInitScreen(CompPlugin * p, CompScreen * s)
-{
- TrailFocusScreen *tfs;
- TrailFocusDisplay *tfd;
-
- tfd = GET_TRAILFOCUS_DISPLAY(s->display);
-
- tfs = malloc(sizeof(TrailFocusScreen));
- if (!tfs)
- {
- return FALSE;
- }
-
- tfs->windowPrivateIndex = allocateWindowPrivateIndex(s);
- if (tfs->windowPrivateIndex < 0)
- {
- free(tfs);
- return FALSE;
- }
-
- trailFocusScreenInitOptions(tfs);
-
- s->privates[tfd->screenPrivateIndex].ptr = tfs;
-
- WRAP(tfs, s, paintWindow, trailFocusPaintWindow);
- WRAP(tfs, s, preparePaintScreen, trailFocusPreparePaintScreen);
-
- return TRUE;
-}
-
-/* screen exit */
-static void trailFocusFiniScreen(CompPlugin * p, CompScreen * s)
-{
- TrailFocusScreen *tfs = GET_TRAILFOCUS_SCREEN(s);
-
- freeWindowPrivateIndex(s, tfs->windowPrivateIndex);
-
- UNWRAP(tfs, s, paintWindow);
- UNWRAP(tfs, s, preparePaintScreen);
-
- free(tfs);
-}
-
-/* a screen option has changed */
-static Bool
-trailFocusSetScreenOption(CompScreen * s, char *name, CompOptionValue * value)
-{
- int index;
- CompOption *o;
- TrailFocusScreen *tfs;
-
- tfs = GET_TRAILFOCUS_SCREEN(s);
- o = compFindOption(tfs->opt, NUM_OPTIONS(tfs), name, &index);
-
- if (!o)
- {
- return FALSE;
- }
-
- /* todo: optimize with a dictionary (hashmap) */
- switch (index)
- {
- case TRAILFOCUS_SCREEN_OPTION_IGNORE_SKIPPAGER:
- case TRAILFOCUS_SCREEN_OPTION_IGNORE_SKIPTASKBAR:
- if (compSetBoolOption(o, value))
- {
- damageScreen(s);
- return TRUE;
- }
- break;
- case TRAILFOCUS_SCREEN_OPTION_MINIMUM_OPACITY_LEVEL:
- if (compSetIntOption(o, value))
- {
- tfs->minOpacityLevel = o->value.i;
- damageScreen(s);
- return TRUE;
- }
- break;
-
- case TRAILFOCUS_SCREEN_OPTION_MINIMUM_SATURATION_LEVEL:
- if (compSetIntOption(o, value))
- {
- tfs->minSaturationLevel = value->i;
- damageScreen(s);
- return TRUE;
- }
- break;
-
- case TRAILFOCUS_SCREEN_OPTION_MINIMUM_BRIGHTNESS_LEVEL:
- if (compSetIntOption(o, value))
- {
- tfs->minBrightnessLevel = value->i;
- damageScreen(s);
- return TRUE;
- }
- break;
- case TRAILFOCUS_SCREEN_OPTION_MAXIMUM_OPACITY_LEVEL:
- if (compSetIntOption(o, value))
- {
- tfs->maxOpacityLevel = o->value.i;
- damageScreen(s);
- return TRUE;
- }
- break;
-
- case TRAILFOCUS_SCREEN_OPTION_MAXIMUM_SATURATION_LEVEL:
- if (compSetIntOption(o, value))
- {
- tfs->maxSaturationLevel = value->i;
- damageScreen(s);
- return TRUE;
- }
- break;
-
- case TRAILFOCUS_SCREEN_OPTION_MAXIMUM_BRIGHTNESS_LEVEL:
- if (compSetIntOption(o, value))
- {
- tfs->maxBrightnessLevel = value->i;
- damageScreen(s);
- return TRUE;
- }
- break;
-
- case TRAILFOCUS_SCREEN_OPTION_MAXIMUM_TRAIL_COUNT:
- if (compSetIntOption(o, value))
- {
- tfs->maxTrailCount = value->i;
- damageScreen(s);
- return TRUE;
- }
- break;
-
- case TRAILFOCUS_SCREEN_OPTION_WINDOW_TYPE:
- if (compSetOptionList(o, value))
- {
- tfs->wmask = compWindowTypeMaskFromStringList(&o->value);
- damageScreen(s);
- return TRUE;
- }
- break;
-
- case TRAILFOCUS_SCREEN_OPTION_EXCLUDE_LIST:
- case TRAILFOCUS_SCREEN_OPTION_DISABLE_ON_SCREENGRAB_OF:
- if (compSetOptionList(o, value))
- return TRUE;
- break;
-
- default:
- break;
- }
-
- return FALSE;
-}
-
-
-/* return our options */
-static CompOption *trailFocusGetScreenOptions(CompScreen * screen, int *count)
-{
- if (screen)
- {
- TrailFocusScreen *tfs = GET_TRAILFOCUS_SCREEN(screen);
-
- *count = NUM_OPTIONS(tfs);
- return tfs->opt;
- }
- else
- {
- TrailFocusScreen *tfs = malloc(sizeof(TrailFocusScreen));
-
- trailFocusScreenInitOptions(tfs);
- *count = NUM_OPTIONS(tfs);
- return tfs->opt;
- }
-}
-
-/* window begin */
-static Bool trailFocusInitWindow(CompPlugin * p, CompWindow * w)
-{
- TrailFocusScreen *tfs = GET_TRAILFOCUS_SCREEN(w->screen);
-
- TrailFocusWindow *tfw = malloc(sizeof(TrailFocusWindow));
-
- if (!tfw)
- {
- return FALSE;
- }
-
- tfw->saturation = 0;
- tfw->brightness = 0;
- tfw->opacity = 0;
- tfw->isUpdated = FALSE;
- tfw->position = 0;
-
- w->privates[tfs->windowPrivateIndex].ptr = tfw;
-
- return TRUE;
-}
-
-/* window end */
-static void trailFocusFiniWindow(CompPlugin * p, CompWindow * w)
-{
- TrailFocusScreen *tfs = GET_TRAILFOCUS_SCREEN(w->screen);
- TrailFocusWindow *tfw = GET_TRAILFOCUS_WINDOW(w, tfs);
-
- free(tfw);
-}
-
-/* trailfocus definitions ------------------------------------------------ */
-
-
-static Bool
-trailFocusPaintWindow(CompWindow * w,
- const WindowPaintAttrib * attrib,
- Region region, unsigned int mask)
-{
- TrailFocusScreen *tfs = GET_TRAILFOCUS_SCREEN(w->screen);
- TrailFocusWindow *tfw = GET_TRAILFOCUS_WINDOW(w, tfs);
-
- Bool status;
- WindowPaintAttrib tfAttrib = *attrib;
-
- int i = 0;
- Bool active = TRUE;
-
- for (i = 0;
- i <
- tfs->opt[TRAILFOCUS_SCREEN_OPTION_DISABLE_ON_SCREENGRAB_OF].
- value.list.nValue; i++)
- {
- active &=
- !screenGrabExist(w->screen,
- tfs->
- opt
- [TRAILFOCUS_SCREEN_OPTION_DISABLE_ON_SCREENGRAB_OF].
- value.list.value[i].s, 0);
- }
-
- if (tfw->isActive & active)
- {
- tfAttrib.opacity = MIN(tfw->opacity, tfAttrib.opacity);
- tfAttrib.brightness = MIN(tfw->brightness, tfAttrib.brightness);
- tfAttrib.saturation = MIN(tfw->saturation, tfAttrib.saturation);
- }
-
- UNWRAP(tfs, w->screen, paintWindow);
- status = (*w->screen->paintWindow) (w, &tfAttrib, region, mask);
- WRAP(tfs, w->screen, paintWindow, trailFocusPaintWindow);
- return status;
-}
-
-static Bool isTrailFocusWindow(CompScreen * s, CompWindow * w)
-{
-
- TrailFocusScreen *tfs = GET_TRAILFOCUS_SCREEN(w->screen);
- CompOption *o;
- int i;
-
-
- if (WINDOW_INVISIBLE(w))
- return FALSE;
- if (w->state & CompWindowStateHiddenMask)
- return FALSE;
-
- if (tfs->opt[TRAILFOCUS_SCREEN_OPTION_IGNORE_SKIPTASKBAR].value.b
- && w->state & CompWindowStateSkipTaskbarMask)
- return FALSE;
- if (tfs->opt[TRAILFOCUS_SCREEN_OPTION_IGNORE_SKIPPAGER].value.b
- && w->state & CompWindowStateSkipPagerMask)
- return FALSE;
- if (!(tfs->wmask & w->type))
- return FALSE;
-
- o = &tfs->opt[TRAILFOCUS_SCREEN_OPTION_EXCLUDE_LIST];
- for (i = 0; i < o->value.list.nValue; i++)
- {
- if (w->resClass
- && (strcmp(o->value.list.value[i].s, w->resClass) == 0))
- return FALSE;
- }
-
- return TRUE;
-}
-
-static void trailFocusPreparePaintScreen(CompScreen * s, int ms)
-{
- TrailFocusScreen *tfs = GET_TRAILFOCUS_SCREEN(s);
- TrailFocusWindow *tfw;
-
- float sat, bright, opacity;
- float sa_step, br_step, op_step;
-
- int count = 0;
-
- CompWindow *w, *activeWindow;
-
- activeWindow = findWindowAtDisplay(s->display, s->display->activeWindow);
- if (!activeWindow)
- {
- UNWRAP(tfs, s, preparePaintScreen);
- (*s->preparePaintScreen) (s, ms);
- WRAP(tfs, s, preparePaintScreen, trailFocusPreparePaintScreen);
- return;
- }
-
- for (w = s->reverseWindows; w; w = w->prev)
- {
- if (isTrailFocusWindow(s, w))
- {
- tfw = GET_TRAILFOCUS_WINDOW(w, tfs);
- tfw->isUpdated = FALSE;
- count++;
- }
- }
-
- count = MAX(1, MIN(tfs->maxTrailCount, count - 1));
- tfw = GET_TRAILFOCUS_WINDOW(activeWindow, tfs);
- tfw->position = count;
- tfw->isUpdated = TRUE;
-
- int i;
- int max_pos;
- TrailFocusWindow *max_win, *tmp_win;
-
- for (i = count - 1; i >= 0; i--)
- {
- max_win = NULL;
- max_pos = -1;
- for (w = s->reverseWindows; w; w = w->prev)
- {
- tmp_win = GET_TRAILFOCUS_WINDOW(w, tfs);
- if (isTrailFocusWindow(s, w))
- {
- if (tmp_win->position > max_pos && !tmp_win->isUpdated)
- {
- max_pos = tmp_win->position;
- max_win = tmp_win;
- }
- }
- else
- {
- tmp_win->position = 0;
- }
- }
- if (max_win)
- {
- max_win->isUpdated = TRUE;
- max_win->position = i;
- }
- }
-
- sa_step =
- (tfs->maxSaturationLevel -
- tfs->minSaturationLevel) / (float)count;
- br_step =
- (tfs->maxBrightnessLevel -
- tfs->minBrightnessLevel) / (float)count;
- op_step = (tfs->maxOpacityLevel - tfs->minOpacityLevel) / (float)count;
- for (w = s->reverseWindows; w; w = w->prev)
- {
- tfw = GET_TRAILFOCUS_WINDOW(w, tfs);
- tfw->isActive = isTrailFocusWindow(s, w);
- if (tfw->isActive)
- {
- sat = tfs->minSaturationLevel;
- bright = tfs->minBrightnessLevel;
- opacity = tfs->minOpacityLevel;
-
- if (tfw->isUpdated)
- {
- sat += sa_step * tfw->position;
- bright += br_step * tfw->position;
- opacity += op_step * tfw->position;
- }
-
- sat = sat * 0xffff / 100.0;
- bright = bright * 0xffff / 100.0;
- opacity = opacity * 0xffff / 100.0;
-
- if (sat != tfw->saturation
- || bright != tfw->brightness || opacity != tfw->opacity)
- addWindowDamage(w);
- tfw->saturation = sat;
- tfw->brightness = bright;
- tfw->opacity = opacity;
- count = MAX(0, count - 1);
- }
- }
- UNWRAP(tfs, s, preparePaintScreen);
- (*s->preparePaintScreen) (s, ms);
- WRAP(tfs, s, preparePaintScreen, trailFocusPreparePaintScreen);
-}
diff --git a/beryl-plugins/src/trailfocus2.c b/beryl-plugins/src/trailfocus2.c
new file mode 100644
index 0000000..14ec593
--- /dev/null
+++ b/beryl-plugins/src/trailfocus2.c
@@ -0,0 +1,716 @@
+/**
+ * Beryl Trailfocus - take three
+ *
+ * Copyright (c) 2006 Kristian Lyngstøl <kristian@beryl-project.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * This version is completly rewritten from scratch with opacify as a
+ * basic template. The original trailfocus was written by:
+ * François Ingelrest <Athropos@gmail.com> and rewritten by:
+ * Dennis Kasprzyk <onestone@beryl-project.org>
+ *
+ *
+ * Trailfocus modifies the opacity, brightness and saturation on a window
+ * based on when it last had focus.
+ *
+ * TODO:
+ * - Binding for ignore-toggeling? This should not be necesarry with
+ * the new paint-attrib system (hopefully).
+ * - Compare behavior with the old trailfocus.
+ * - Use the new paint-attrib-changing method when it is defined.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <math.h>
+#include <X11/Xatom.h>
+#include <X11/extensions/Xrender.h>
+#include <beryl.h>
+
+#define GET_TRAILFOCUS_DISPLAY(d) \
+ ((TrailfocusDisplay *) (d)->privates[displayPrivateIndex].ptr)
+#define TRAILFOCUS_DISPLAY(d) \
+ TrailfocusDisplay *td = GET_TRAILFOCUS_DISPLAY (d)
+#define GET_TRAILFOCUS_SCREEN(s, td) \
+ ((TrailfocusScreen *) (s)->privates[(td)->screenPrivateIndex].ptr)
+#define TRAILFOCUS_SCREEN(s) \
+ TrailfocusScreen *ts = GET_TRAILFOCUS_SCREEN (s, GET_TRAILFOCUS_DISPLAY (s->display))
+
+#define NUM_OPTIONS(s) (sizeof ((s)->opt) / sizeof (CompOption))
+#define N_WIN_TYPE (sizeof (winType) / sizeof (winType[0]))
+
+static int displayPrivateIndex = 0;
+
+static char *winType[] = {
+ N_("Toolbar"),
+ N_("Utility"),
+ N_("Dialog"),
+ N_("ModalDialog"),
+ N_("Fullscreen"),
+ N_("Normal")
+};
+
+typedef enum _TfOpt
+{
+ SOPT_MAX_OPACITY = 0,
+ SOPT_MAX_BRIGHTNESS,
+ SOPT_MAX_SATURATION,
+ SOPT_MIN_OPACITY,
+ SOPT_MIN_BRIGHTNESS,
+ SOPT_MIN_SATURATION,
+ SOPT_WINDOWS,
+ SOPT_WINDOW_TYPE,
+ SOPT_EXCLUDE_LIST,
+ SOPT_IGNORE_SKIPTASKBAR,
+ SOPT_IGNORE_SKIPPAGER,
+ SOPT_NUM
+} TrailfocusScreenOptions;
+
+typedef struct _TrailfocusDisplay
+{
+ int screenPrivateIndex;
+ HandleEventProc handleEvent;
+} TrailfocusDisplay;
+
+typedef struct _TfWindowAttributes
+{
+ GLushort opacity;
+ GLushort brightness;
+ GLushort saturation;
+} TfAttrib;
+
+typedef struct _TrailfocusScreen
+{
+ int wMask;
+ Window *win;
+ int win_max;
+ TfAttrib *inc;
+ CompOption opt[SOPT_NUM];
+} TrailfocusScreen;
+
+/* Core trailfocus functions. These do the real work. ---------------*/
+
+/* Checks if a window is a window trailfocus is supposed to touch or not. */
+static Bool is_trailfocus_window(TrailfocusScreen * ts, CompWindow * w)
+{
+ int i;
+ CompOption *o;
+
+ if (!(w->type & ts->wMask))
+ return False;
+ o = &ts->opt[SOPT_EXCLUDE_LIST];
+ for (i = 0; i < o->value.list.nValue; i++)
+ {
+ if (w->resClass
+ && (strcmp(o->value.list.value[i].s, w->resClass) == 0))
+ return False;
+ }
+
+ if (ts->opt[SOPT_IGNORE_SKIPTASKBAR].value.b
+ && w->state & CompWindowStateSkipTaskbarMask)
+ return False;
+ if (ts->opt[SOPT_IGNORE_SKIPPAGER].value.b
+ && w->state & CompWindowStateSkipPagerMask)
+ return False;
+
+ return True;
+}
+
+/* The set_[opacity|brightness|saturation] functions of
+ * trailfocus modifies the atoms if necesarry. These modify the actual
+ * atom, and also do not check if the window supplied is valid.
+ * FIXME: These are not permanent. We should not have to change the atom.
+ */
+static void set_opacity(CompWindow * w, int opacity)
+{
+ if (w->paint.opacity == opacity && w->opacity == opacity)
+ return;
+ if(set_default_window_opacity(w, opacity, PL_NO_LOCK))
+ set_window_opacity(w, opacity, PL_NO_LOCK);
+}
+
+static void set_brightness(CompWindow * w, int brightness)
+{
+ if (w->paint.brightness == brightness && w->brightness == brightness)
+ return;
+ if(set_default_window_brightness(w, brightness, PL_NO_LOCK))
+ set_window_brightness(w, brightness, PL_NO_LOCK);
+}
+
+static void set_saturation(CompWindow * w, int sat)
+{
+ if (w->paint.saturation == sat && w->saturation == sat)
+ return;
+ if(set_default_window_saturation(w, sat, PL_NO_LOCK))
+ set_window_saturation(w, sat, PL_NO_LOCK);
+}
+
+/* Resets a window's paint attribute when we're bailing out. Ideally this should
+ * reset to the atom, we're waiting for a proper paint-backend. In the meanwhile
+ * we're doing 0xFFFF. This is meant for plugin unload or when we are suddenly
+ * no longer handeling a window.
+ * FIXME: These are NOT PERMANENT AND NOT CORRECT. This is merely a
+ * place-holder until a more proper system has been put in place.
+ */
+static void bail_out_window(CompWindow * w)
+{
+ if (UNLIKELY(!w))
+ return;
+ set_window_bailout_opacity(w, PL_NO_LOCK);
+ set_window_bailout_saturation(w, PL_NO_LOCK);
+ set_window_bailout_brightness(w, PL_NO_LOCK);
+ reset_window_opacity(w, PL_NO_LOCK);
+ reset_window_saturation(w, PL_NO_LOCK);
+ reset_window_brightness(w, PL_NO_LOCK);
+}
+
+/* Meant for unload. Reset all windows handled by us. */
+static void bail_out_tf(CompScreen * s)
+{
+ CompWindow *w;
+
+ TRAILFOCUS_SCREEN(s);
+
+ for (w = s->windows; w; w = w->next)
+ if (is_trailfocus_window(ts, w))
+ bail_out_window(w);
+}
+
+/* Meant for option change. Reset all windows not handled by us.
+ * Ideally we should have a window-diff here, but alas... we don't.
+ * So we reset all we don't handle. Room for improvement if necesarry.
+ */
+static void bail_out_non_tf(CompScreen * s)
+{
+ CompWindow *w;
+
+ TRAILFOCUS_SCREEN(s);
+
+ for (w = s->windows; w; w = w->next)
+ if (!is_trailfocus_window(ts, w))
+ bail_out_window(w);
+}
+
+/* Sets the opacity, saturation and brightness to that of a window
+ * that had focus N times ago.
+ */
+static inline void set_window(TrailfocusScreen * ts, CompWindow * w, int n)
+{
+ set_opacity(w, ts->inc[n].opacity);
+ set_saturation(w, ts->inc[n].saturation);
+ set_brightness(w, ts->inc[n].brightness);
+}
+
+/* Walks through the window-list and sets the opacity-levels for
+ * all windows. The inner loop will result in ts->win[i] either
+ * representing a recently focused window, or the least
+ * focused window.
+ */
+static void set_windows(CompScreen * s)
+{
+ CompWindow *w;
+
+ TRAILFOCUS_SCREEN(s);
+ int i = 0;
+
+ for (w = s->windows; w; w = w->next)
+ {
+ if (w->invisible || w->hidden || w->minimized)
+ continue;
+ if (!is_trailfocus_window(ts, w))
+ continue;
+ for (i = 0; i < ts->win_max; i++)
+ if (w->id == ts->win[i])
+ break;
+ set_window(ts, w, i);
+ }
+}
+
+/* Push a new window-id on the trailfocus window-stack (not to be
+ * confused with the real window stack). Only keep one copy of a
+ * window on the stack. If the window allready exist on the stack,
+ * move it to the top.
+ */
+static CompScreen *push_window(CompDisplay * d, Window id)
+{
+ int i;
+ short int tmp;
+ CompWindow *w;
+ CompScreen *s;
+
+ w = findWindowAtDisplay(d, id);
+ if (UNLIKELY(!w))
+ return NULL;
+ s = w->screen;
+ if (UNLIKELY(!s))
+ return NULL;
+ TRAILFOCUS_SCREEN(s);
+ if (!is_trailfocus_window(ts, w))
+ return NULL;
+
+ tmp = ts->win_max;
+ for (i = 0; i < ts->win_max; i++)
+ if (ts->win[i] == id)
+ break;
+
+ if (UNLIKELY(i == 0))
+ return NULL;
+
+ for (; i > 0; i--)
+ ts->win[i] = ts->win[i - 1];
+
+ ts->win[0] = id;
+ return s;
+}
+
+/* Find a window on a screen.... Unlike the findWindowAtScreen which
+ * core provides, we don't intend to search for the same window several
+ * times in a row so we optimize for* the normal situation of searching for
+ * a window only once in a row.
+ */
+static CompWindow *find_window(CompScreen * s, Window id)
+{
+ CompWindow *w;
+
+ for (w = s->windows; w; w = w->next)
+ if (w->id == id)
+ return w;
+ return NULL;
+}
+
+/* Walks through the existing stack and removes windows that should
+ * (no longer) be there. Used for option-change.
+ */
+static void clean_list(CompScreen * s)
+{
+ TRAILFOCUS_SCREEN(s);
+ CompWindow *w;
+ int i, j, length;
+
+ for (i = 0; i < ts->win_max; i++)
+ {
+ w = find_window(s, ts->win[i]);
+ if (!w || !is_trailfocus_window(ts, w))
+ ts->win[i] = 0;
+ }
+ length = ts->win_max;
+ for (i = 0; i < length; i++)
+ {
+ if (!ts->win[i])
+ {
+ for (j = i; j < length - 1; j++)
+ ts->win[j] = ts->win[j + 1];
+ length--;
+ }
+ }
+ for (; length < ts->win_max; length++)
+ ts->win[length] = 0;
+}
+
+/* Handles the event if it was a FocusIn event. */
+static void trailfocusHandleEvent(CompDisplay * d, XEvent * event)
+{
+ TRAILFOCUS_DISPLAY(d);
+ CompScreen *s;
+ switch (event->type)
+ {
+ case FocusIn:
+ s = push_window(d, event->xfocus.window);
+ if (s && !otherScreenGrabExist(s,0))
+ set_windows(s);
+ break;
+ default:
+ break;
+ }
+
+
+ UNWRAP(td, d, handleEvent);
+ (*d->handleEvent) (d, event);
+ WRAP(td, d, handleEvent, trailfocusHandleEvent);
+}
+
+/* Settings changed. Reallocate rs->inc and re-populate it and the
+ * rest of the TrailfocusScreen (-wMask).
+ */
+static void recalculate_attributes(TrailfocusScreen * ts)
+{
+ TfAttrib tmp, min, max;
+ int i;
+
+ ts->win_max = ts->opt[SOPT_WINDOWS].value.i;
+ 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->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] = min;
+}
+
+/* Unlike the traditional setScreenOptions, we return on failure in the
+ * switch, so we can execute a couple of common functions at the end.
+ */
+static Bool trailfocusSetScreenOptions(CompScreen * screen, char *name,
+ CompOptionValue * value)
+{
+ CompOption *o;
+ int index;
+
+ TRAILFOCUS_SCREEN(screen);
+ o = compFindOption(ts->opt, NUM_OPTIONS(ts), name, &index);
+ if (!o)
+ return FALSE;
+
+ switch (index)
+ {
+ case SOPT_MAX_OPACITY:
+ case SOPT_MAX_BRIGHTNESS:
+ case SOPT_MAX_SATURATION:
+ case SOPT_MIN_OPACITY:
+ case SOPT_MIN_BRIGHTNESS:
+ case SOPT_MIN_SATURATION:
+ case SOPT_WINDOWS:
+ if (!compSetIntOption(o, value))
+ return FALSE;
+ recalculate_attributes(ts);
+ break;
+ case SOPT_WINDOW_TYPE:
+ if (!compSetOptionList(o, value))
+ return FALSE;
+ ts->wMask = compWindowTypeMaskFromStringList(&o->value);
+ break;
+ case SOPT_EXCLUDE_LIST:
+ if (!compSetOptionList(o, value))
+ return FALSE;
+ break;
+ case SOPT_IGNORE_SKIPPAGER:
+ case SOPT_IGNORE_SKIPTASKBAR:
+ if (!compSetBoolOption(o, value))
+ return FALSE;
+ break;
+ default:
+ return FALSE;
+ break;
+ }
+ bail_out_non_tf(screen);
+ clean_list(screen);
+ push_window(screen->display, screen->display->activeWindow);
+ set_windows(screen);
+
+ return TRUE;
+}
+
+/* Configuration, initliazation, boring stuff. ----------------------- */
+
+/* Remember to reset windows to some sane value when we unload */
+static void trailfocusFiniScreen(CompPlugin * p, CompScreen * s)
+{
+ TRAILFOCUS_SCREEN(s);
+ bail_out_tf(s);
+ if (ts->opt[SOPT_WINDOW_TYPE].value.list.value)
+ free(ts->opt[SOPT_WINDOW_TYPE].value.list.value);
+ free(ts);
+}
+
+static void trailfocusScreenInitOptions(TrailfocusScreen * ts)
+{
+ CompOption *o;
+ int i;
+
+ o = &ts->opt[SOPT_MAX_OPACITY];
+ o->name = "max_opacity";
+ o->group = N_("Appearance");
+ o->subGroup = N_("Opacity");
+ o->displayHints = "";
+ o->shortDesc = N_("Opacity level of completly focused windows");
+ o->longDesc = N_("Opacity of the currently focused window. Windows "
+ "will get opacity levels between the focused "
+ "and min. ");
+ o->type = CompOptionTypeInt;
+ o->value.i = 100;
+ o->rest.i.min = 1;
+ o->rest.i.max = 100;
+ o->advanced = False;
+
+ o = &ts->opt[SOPT_MAX_BRIGHTNESS];
+ o->name = "max_brightness";
+ o->group = N_("Appearance");
+ o->subGroup = N_("Brightness");
+ o->displayHints = "";
+ o->shortDesc = N_("Brightness level of completly focused windows");
+ o->longDesc = N_("Brightness of the currently focused window. Windows "
+ "will get brightness levels between the focused "
+ "and min. ");
+ o->type = CompOptionTypeInt;
+ o->value.i = 100;
+ o->rest.i.min = 1;
+ o->rest.i.max = 100;
+ o->advanced = False;
+
+ o = &ts->opt[SOPT_MAX_SATURATION];
+ o->name = "max_saturation";
+ o->group = N_("Appearance");
+ o->subGroup = N_("Saturation");
+ o->displayHints = "";
+ o->shortDesc = N_("Saturation level of completly focused windows");
+ o->longDesc = N_("Saturation of the currently focused window. Windows "
+ "will get saturation levels between the focused "
+ "and min. ");
+ o->type = CompOptionTypeInt;
+ o->value.i = 100;
+ o->rest.i.min = 1;
+ o->rest.i.max = 100;
+ o->advanced = False;
+
+ o = &ts->opt[SOPT_MIN_OPACITY];
+ o->name = "min_opacity";
+ o->group = N_("Appearance");
+ o->subGroup = N_("Opacity");
+ o->displayHints = "";
+ o->shortDesc = N_("Opacity level of completly unfocused windows");
+ o->longDesc = N_("Opacity of the least focused windows. Windows "
+ "will get opacity levels between the focused "
+ "and min. ");
+ o->type = CompOptionTypeInt;
+ o->value.i = 70;
+ o->rest.i.min = 1;
+ o->rest.i.max = 100;
+ o->advanced = False;
+
+ o = &ts->opt[SOPT_MIN_BRIGHTNESS];
+ o->name = "min_brightness";
+ o->group = N_("Appearance");
+ o->subGroup = N_("Brightness");
+ o->displayHints = "";
+ o->shortDesc = N_("Brightness level of completly unfocused windows");
+ o->longDesc = N_("Brightness of the least focused windows. Windows "
+ "will get brightness levels between the focused "
+ "and min. ");
+ o->type = CompOptionTypeInt;
+ o->value.i = 90;
+ o->rest.i.min = 1;
+ o->rest.i.max = 100;
+ o->advanced = False;
+
+ o = &ts->opt[SOPT_MIN_SATURATION];
+ o->name = "min_saturation";
+ o->group = N_("Appearance");
+ o->subGroup = N_("Saturation");
+ o->displayHints = "";
+ o->shortDesc = N_("Saturation level of completly unfocused windows");
+ o->longDesc = N_("Saturation of the least focused windows. Windows "
+ "will get saturation levels between the focused "
+ "and min. ");
+ o->type = CompOptionTypeInt;
+ o->value.i = 90;
+ o->rest.i.min = 1;
+ o->rest.i.max = 100;
+ o->advanced = False;
+
+ o = &ts->opt[SOPT_WINDOWS];
+ o->name = "windows";
+ o->group = N_("Behaviour");
+ o->subGroup = N_("");
+ o->displayHints = "";
+ o->shortDesc = N_("Number of windows to track");
+ o->longDesc =
+ N_
+ ("Number of windows trailfocus will keep track of. Windows had focus "
+ " this amount of windows ago or more, will be considered completly"
+ " unfocused.");
+ o->type = CompOptionTypeInt;
+ o->value.i = 5;
+ o->rest.i.min = 1;
+ o->rest.i.max = 150;
+ o->advanced = False;
+ ts->win_max = 5;
+
+
+ o = &ts->opt[SOPT_WINDOW_TYPE];
+ o->name = "window_types";
+ o->group = N_("Behaviour");
+ o->subGroup = N_("");
+ o->displayHints = "";
+ o->shortDesc = N_("Window Types");
+ o->longDesc = N_("Window types that should be handled by trailfocus");
+ o->type = CompOptionTypeList;
+ o->value.list.type = CompOptionTypeString;
+ o->value.list.nValue = N_WIN_TYPE;
+ o->value.list.value = malloc(sizeof(CompOptionValue) * N_WIN_TYPE);
+ for (i = 0; i < N_WIN_TYPE; i++)
+ o->value.list.value[i].s = strdup(winType[i]);
+ o->rest.s.string = (char **)windowTypeString;
+ o->rest.s.nString = nWindowTypeString;
+ o->advanced = True;
+
+ o = &ts->opt[SOPT_EXCLUDE_LIST];
+ o->advanced = False;
+ o->name = "exclude_list";
+ o->group = N_("Behaviour");
+ o->subGroup = N_("");
+ o->displayHints = "";
+ o->shortDesc = N_("WM_CLASS to exclude");
+ o->longDesc =
+ N_
+ ("Windows classes to exclude from trailfocusing. Use xprop to find window class.");
+ o->type = CompOptionTypeList;
+ o->value.list.type = CompOptionTypeString;
+ o->value.list.nValue = 0;
+ o->value.list.value = 0;
+ o->rest.s.string = 0;
+ o->rest.s.nString = 0;
+
+ o = &ts->opt[SOPT_IGNORE_SKIPTASKBAR];
+ o->advanced = True;
+ o->name = "ignore_skiptaskbar";
+ o->group = N_("Behaviour");
+ o->subGroup = N_("");
+ o->displayHints = "";
+ o->shortDesc = N_("Ignore \"SkipTaskbar\" Windows");
+ o->longDesc = N_("Ignore \"SkipTaskbar\" Windows");
+ o->type = CompOptionTypeBool;
+ o->value.b = True;
+
+ o = &ts->opt[SOPT_IGNORE_SKIPPAGER];
+ o->advanced = True;
+ o->name = "ignore_skippager";
+ o->group = N_("Behaviour");
+ o->subGroup = N_("");
+ o->displayHints = "";
+ o->shortDesc = N_("Ignore \"SkipPager\" Windows");
+ o->longDesc = N_("Ignore \"SkipPager\" Windows");
+ o->type = CompOptionTypeBool;
+ o->value.b = True;
+}
+
+/* Remember to populate the TrailFocus screen properly, and push the
+ * active window on the stack, then set windows.
+ */
+static Bool trailfocusInitScreen(CompPlugin * p, CompScreen * s)
+{
+ TRAILFOCUS_DISPLAY(s->display);
+ TrailfocusScreen *ts =
+ (TrailfocusScreen *) calloc(1, sizeof(TrailfocusScreen));
+ s->privates[td->screenPrivateIndex].ptr = ts;
+ trailfocusScreenInitOptions(ts);
+ ts->wMask =
+ compWindowTypeMaskFromStringList(&ts->opt[SOPT_WINDOW_TYPE].
+ value);
+ recalculate_attributes(ts);
+ push_window(s->display, s->display->activeWindow);
+ set_windows(s);
+ return TRUE;
+}
+
+static CompOption *trailfocusGetScreenOptions(CompScreen * screen, int *count)
+{
+ if (screen)
+ {
+ TRAILFOCUS_SCREEN(screen);
+ *count = NUM_OPTIONS(ts);
+ return ts->opt;
+ }
+ else
+ {
+ TrailfocusScreen *ts = malloc(sizeof(TrailfocusScreen));
+
+ trailfocusScreenInitOptions(ts);
+ *count = NUM_OPTIONS(ts);
+ return ts->opt;
+ }
+}
+
+static Bool trailfocusInitDisplay(CompPlugin * p, CompDisplay * d)
+{
+ TrailfocusDisplay *td =
+ (TrailfocusDisplay *) malloc(sizeof(TrailfocusDisplay));
+
+ td->screenPrivateIndex = allocateScreenPrivateIndex(d);
+ if (td->screenPrivateIndex < 0)
+ {
+ free(td);
+ return FALSE;
+ }
+ d->privates[displayPrivateIndex].ptr = td;
+ WRAP(td, d, handleEvent, trailfocusHandleEvent);
+ return TRUE;
+}
+
+static void trailfocusFiniDisplay(CompPlugin * p, CompDisplay * d)
+{
+ TRAILFOCUS_DISPLAY(d);
+ UNWRAP(td, d, handleEvent);
+ freeScreenPrivateIndex(d, td->screenPrivateIndex);
+ free(td);
+}
+
+static Bool trailfocusInit(CompPlugin * p)
+{
+ displayPrivateIndex = allocateDisplayPrivateIndex();
+ if (displayPrivateIndex < 0)
+ return FALSE;
+ return TRUE;
+}
+
+static void trailfocusFini(CompPlugin * p)
+{
+ if (displayPrivateIndex >= 0)
+ freeDisplayPrivateIndex(displayPrivateIndex);
+}
+
+CompPluginVTable trailfocusVTable = {
+ "trailfocus2",
+ N_("Trailfocus"),
+ N_("Adjust the opacity, saturation and brightness of windows based on when they last had focus."),
+ trailfocusInit,
+ trailfocusFini,
+ trailfocusInitDisplay,
+ trailfocusFiniDisplay,
+ trailfocusInitScreen,
+ trailfocusFiniScreen,
+ 0,
+ 0,
+ 0, // trailfocusGetDisplayOptions,
+ 0, // trailfocusSetDisplayOptions,
+ trailfocusGetScreenOptions,
+ trailfocusSetScreenOptions,
+ 0,
+ 0,
+ 0,
+ 0,
+ BERYL_ABI_INFO,
+ "beryl-plugins",
+ "effects",
+ 0,
+ 0,
+ False,
+};
+
+CompPluginVTable *getCompPluginInfo(void)
+{
+ return &trailfocusVTable;
+}
diff --git a/beryl-settings/images/Makefile.am b/beryl-settings/images/Makefile.am
index d309e0f..6e6d19d 100644
--- a/beryl-settings/images/Makefile.am
+++ b/beryl-settings/images/Makefile.am
@@ -38,7 +38,7 @@ images_DATA = \
beryl-settings-section-state.svg \
beryl-settings-section-svg.svg \
beryl-settings-section-switcher.svg \
- beryl-settings-section-trailfocus.svg \
+ beryl-settings-section-trailfocus2.svg \
beryl-settings-section-water.svg \
beryl-settings-section-wobbly.svg \
beryl-settings-section-zoom.svg
diff --git a/beryl-settings/images/beryl-settings-section-trailfocus.svg b/beryl-settings/images/beryl-settings-section-trailfocus2.svg
index 2e85b36..2e85b36 100644
--- a/beryl-settings/images/beryl-settings-section-trailfocus.svg
+++ b/beryl-settings/images/beryl-settings-section-trailfocus2.svg