summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Reveman <c99drn@cs.umu.se>2006-03-17 13:16:31 +0000
committerDavid Reveman <c99drn@cs.umu.se>2006-03-17 13:16:31 +0000
commitdb8b46b25b2fe532779e5bd8589841ee8b80bf04 (patch)
treee97873455499ce08e9280da40d9700f7a6cfe364
parente82ab9442618c1699e0fa05ddc515cad3ddcd5f4 (diff)
downloadunity-window-decorator-db8b46b25b2fe532779e5bd8589841ee8b80bf04.tar.gz
unity-window-decorator-db8b46b25b2fe532779e5bd8589841ee8b80bf04.tar.bz2
Add opacity option to scale plugin
-rw-r--r--ChangeLog2
-rw-r--r--plugins/scale.c40
2 files changed, 38 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index b26df5d..6d605d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2006-03-17 David Reveman <davidr@novell.com>
+ * plugins/scale.c: Add opacity option.
+
* configure.ac: Bump version to 0.0.7.
2006-03-17 Radek Doulik <rodo@novell.com>
diff --git a/plugins/scale.c b/plugins/scale.c
index 6f268b6..f526f34 100644
--- a/plugins/scale.c
+++ b/plugins/scale.c
@@ -70,6 +70,10 @@
#define SCALE_DARKEN_BACK_DEFAULT TRUE
+#define SCALE_OPACITY_DEFAULT 75
+#define SCALE_OPACITY_MIN 0
+#define SCALE_OPACITY_MAX 100
+
static char *winType[] = {
"Toolbar",
"Utility",
@@ -101,7 +105,8 @@ typedef struct _ScaleDisplay {
#define SCALE_SCREEN_OPTION_TIMESTEP 6
#define SCALE_SCREEN_OPTION_WINDOW_TYPE 7
#define SCALE_SCREEN_OPTION_DARKEN_BACK 8
-#define SCALE_SCREEN_OPTION_NUM 9
+#define SCALE_SCREEN_OPTION_OPACITY 9
+#define SCALE_SCREEN_OPTION_NUM 10
typedef struct _ScaleScreen {
int windowPrivateIndex;
@@ -143,7 +148,8 @@ typedef struct _ScaleScreen {
GLfloat scale;
- Bool darkenBack;
+ Bool darkenBack;
+ GLushort opacity;
} ScaleScreen;
typedef struct _ScaleWindow {
@@ -255,7 +261,12 @@ scaleSetScreenOption (CompScreen *screen,
ss->darkenBack = o->value.b;
return TRUE;
}
- break;
+ case SCALE_SCREEN_OPTION_OPACITY:
+ if (compSetIntOption (o, value))
+ {
+ ss->opacity = (OPAQUE * o->value.i) / 100;
+ return TRUE;
+ }
default:
break;
}
@@ -360,6 +371,15 @@ scaleScreenInitOptions (ScaleScreen *ss,
o->longDesc = "Darken background when scaling windows";
o->type = CompOptionTypeBool;
o->value.b = SCALE_DARKEN_BACK_DEFAULT;
+
+ o = &ss->opt[SCALE_SCREEN_OPTION_OPACITY];
+ o->name = "opacity";
+ o->shortDesc = "Opacity";
+ o->longDesc = "Amount of opacity in percent";
+ o->type = CompOptionTypeInt;
+ o->value.i = SCALE_OPACITY_DEFAULT;
+ o->rest.i.min = SCALE_OPACITY_MIN;
+ o->rest.i.max = SCALE_OPACITY_MAX;
}
static Bool
@@ -380,10 +400,21 @@ scalePaintWindow (CompWindow *w,
if (sw->adjust || sw->slot)
{
mask |= PAINT_WINDOW_TRANSFORMED_MASK;
+
+ if (w->id != s->display->activeWindow &&
+ ss->opacity != OPAQUE &&
+ ss->state != SCALE_STATE_IN)
+ {
+ /* modify opacity of windows that are not active */
+ sAttrib = *attrib;
+ attrib = &sAttrib;
+
+ sAttrib.opacity = (sAttrib.opacity * ss->opacity) >> 16;
+ }
}
else if (ss->darkenBack && ss->state != SCALE_STATE_IN)
{
- /* Modify brightness of the other windows */
+ /* modify brightness of the other windows */
sAttrib = *attrib;
attrib = &sAttrib;
@@ -1179,6 +1210,7 @@ scaleInitScreen (CompPlugin *p,
ss->speed = SCALE_SPEED_DEFAULT;
ss->timestep = SCALE_TIMESTEP_DEFAULT;
+ ss->opacity = (OPAQUE * SCALE_OPACITY_DEFAULT) / 100;
scaleScreenInitOptions (ss, s->display->display);