[compiz] [PATCH] plugin conflict resolution between Fade & Animation

Erkin Bahceci erkinbah at gmail.com
Sun Jul 1 19:44:37 PDT 2007


Hi,

Having the minimize_open_close option in Fade wasn't enough for
conflict resolution with Animation, since it was on by default. This
makes sense since the Minimize plugin is used by default, which is a
lightweight animation provider that some people/distributions might
prefer over Animation. And nobody really needs to know that this
option resolves the conflict. So here is a better method to resolve
the conflict with animation.

The first patch adds a compiz-event handler to Fade that handles
animation's activate event to suppress fade on minimize/open/close.
The activate event doesn't identify the window being animated. It just
tells that there is an animation going on, which is enough for Fade to
resolve the conflict. Since Fade doesn't need to use
findWindowAtScreen, the performance impact is independent of the
number of windows and should be negligible.

The second patch removes the minimize_open_close option since it's not
necessary anymore (it was introduced to resolve the conflict). I guess
the option is not used for any other purpose by anybody. So it should
be safe to remove.

Especially the first patch is necessary to fix the conflict for good.

Regards,
Erkin
-------------- next part --------------
From 2970404517e7ec73a080c58fa52b5644f1c05b67 Mon Sep 17 00:00:00 2001
From: Erkin Bahceci <erkinbah at gmail.com>
Date: Sun, 1 Jul 2007 22:14:52 -0400
Subject: [PATCH] Handle animation activate compiz event to avoid conflict.
(on minimize/open/close events only)
---
 plugins/fade.c |   42 ++++++++++++++++++++++++++++++++++++++----
 1 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/plugins/fade.c b/plugins/fade.c
index 7dc967b..5086df3 100644
--- a/plugins/fade.c
+++ b/plugins/fade.c
@@ -35,6 +35,7 @@ static int displayPrivateIndex;
 typedef struct _FadeDisplay {
     int			       screenPrivateIndex;
     HandleEventProc	       handleEvent;
+    HandleCompizEventProc      handleCompizEvent;
     MatchExpHandlerChangedProc matchExpHandlerChanged;
     int			       displayModals;
 } FadeDisplay;
@@ -49,6 +50,7 @@ typedef struct _FadeDisplay {
 typedef struct _FadeScreen {
     int			   windowPrivateIndex;
     int			   fadeTime;
+    Bool		   suppressMinimizeOpenClose;
 
     CompOption opt[FADE_SCREEN_OPTION_NUM];
 
@@ -409,7 +411,8 @@ fadeHandleEvent (CompDisplay *d,
 	{
 	    FADE_SCREEN (w->screen);
 
-	    if (!fs->opt[FADE_SCREEN_OPTION_MINIMIZE_OPEN_CLOSE].value.b)
+	    if (fs->suppressMinimizeOpenClose ||
+		!fs->opt[FADE_SCREEN_OPTION_MINIMIZE_OPEN_CLOSE].value.b)
 		break;
 
 	    if (w->texture->pixmap && matchEval (&fs->match, w))
@@ -439,7 +442,8 @@ fadeHandleEvent (CompDisplay *d,
 
 	    fw->shaded = w->shaded;
 
-	    if (!fs->opt[FADE_SCREEN_OPTION_MINIMIZE_OPEN_CLOSE].value.b)
+	    if (fs->suppressMinimizeOpenClose ||
+		!fs->opt[FADE_SCREEN_OPTION_MINIMIZE_OPEN_CLOSE].value.b)
 		break;
 
 	    if (!fw->shaded && w->texture->pixmap && matchEval (&fs->match, w))
@@ -464,7 +468,8 @@ fadeHandleEvent (CompDisplay *d,
 	{
 	    FADE_SCREEN(w->screen);
 
-	    if (!fs->opt[FADE_SCREEN_OPTION_MINIMIZE_OPEN_CLOSE].value.b)
+	    if (fs->suppressMinimizeOpenClose ||
+		!fs->opt[FADE_SCREEN_OPTION_MINIMIZE_OPEN_CLOSE].value.b)
 		break;
 
 	    fadeWindowStop (w);
@@ -554,6 +559,30 @@ fadeHandleEvent (CompDisplay *d,
     }
 }
 
+static void fadeHandleCompizEvent(CompDisplay * d, char *pluginName,
+				  char *eventName, CompOption * option, int nOption)
+{
+    FADE_DISPLAY(d);
+
+    UNWRAP (fd, d, handleCompizEvent);
+    (*d->handleCompizEvent) (d, pluginName, eventName, option, nOption);
+    WRAP (fd, d, handleCompizEvent, fadeHandleCompizEvent);
+
+    if (strcmp(pluginName, "animation") == 0 &&
+	strcmp(eventName, "activate") == 0)
+    {
+	Window xid = getIntOptionNamed(option, nOption, "root", 0);
+	CompScreen *s = findScreenAtDisplay(d, xid);
+
+	if (s)
+	{
+	    FADE_SCREEN(s);
+	    fs->suppressMinimizeOpenClose =
+		getBoolOptionNamed(option, nOption, "active", FALSE);
+	}
+    }
+}
+
 static Bool
 fadeDamageWindowRect (CompWindow *w,
 		      Bool	 initial,
@@ -575,7 +604,8 @@ fadeDamageWindowRect (CompWindow *w,
 	}
 	else if (matchEval (&fs->match, w))
 	{
-	    if (fs->opt[FADE_SCREEN_OPTION_MINIMIZE_OPEN_CLOSE].value.b)
+	    if (!fs->suppressMinimizeOpenClose &&
+		fs->opt[FADE_SCREEN_OPTION_MINIMIZE_OPEN_CLOSE].value.b)
 	    {
 		fw->opacity = 0;
 	    }
@@ -659,6 +689,7 @@ fadeInitDisplay (CompPlugin  *p,
     fd->displayModals = 0;
 
     WRAP (fd, d, handleEvent, fadeHandleEvent);
+    WRAP (fd, d, handleCompizEvent, fadeHandleCompizEvent);
     WRAP (fd, d, matchExpHandlerChanged, fadeMatchExpHandlerChanged);
 
     d->privates[displayPrivateIndex].ptr = fd;
@@ -675,6 +706,7 @@ fadeFiniDisplay (CompPlugin *p,
     freeScreenPrivateIndex (d, fd->screenPrivateIndex);
 
     UNWRAP (fd, d, handleEvent);
+    UNWRAP (fd, d, handleCompizEvent);
     UNWRAP (fd, d, matchExpHandlerChanged);
 
     free (fd);
@@ -720,6 +752,8 @@ fadeInitScreen (CompPlugin *p,
 
     fs->fadeTime = 1000.0f / fs->opt[FADE_SCREEN_OPTION_FADE_SPEED].value.f;
 
+    fs->suppressMinimizeOpenClose = FALSE;
+
     matchInit (&fs->match);
 
     fadeUpdateWindowFadeMatch (s->display,
-- 
1.4.4.2
-------------- next part --------------
From 5deb8ec0defb159f8e9d5121fea9435126f52b29 Mon Sep 17 00:00:00 2001
From: Erkin Bahceci <erkinbah at gmail.com>
Date: Sun, 1 Jul 2007 22:15:21 -0400
Subject: [PATCH] Remove minimize_open_close option.
... since conflict with Animation is resolved with compiz events now.
---
 metadata/fade.xml.in |    5 -----
 plugins/fade.c       |   18 ++++++------------
 2 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/metadata/fade.xml.in b/metadata/fade.xml.in
index 2551d7a..3741128 100644
--- a/metadata/fade.xml.in
+++ b/metadata/fade.xml.in
@@ -32,11 +32,6 @@
 		<_long>Fullscreen fade effect on system beep</_long>
 		<default>false</default>
 	    </option>
-	    <option name="minimize_open_close" type="bool">
-		<_short>Fade On Minimize/Open/Close</_short>
-		<_long>Fade effect on minimize/open/close window events</_long>
-		<default>true</default>
-	    </option>
 	</screen>
     </plugin>
 </compiz>
diff --git a/plugins/fade.c b/plugins/fade.c
index 5086df3..e5cab59 100644
--- a/plugins/fade.c
+++ b/plugins/fade.c
@@ -44,8 +44,7 @@ typedef struct _FadeDisplay {
 #define FADE_SCREEN_OPTION_WINDOW_MATCH		  1
 #define FADE_SCREEN_OPTION_VISUAL_BELL		  2
 #define FADE_SCREEN_OPTION_FULLSCREEN_VISUAL_BELL 3
-#define FADE_SCREEN_OPTION_MINIMIZE_OPEN_CLOSE	  4
-#define FADE_SCREEN_OPTION_NUM			  5
+#define FADE_SCREEN_OPTION_NUM			  4
 
 typedef struct _FadeScreen {
     int			   windowPrivateIndex;
@@ -411,8 +410,7 @@ fadeHandleEvent (CompDisplay *d,
 	{
 	    FADE_SCREEN (w->screen);
 
-	    if (fs->suppressMinimizeOpenClose ||
-		!fs->opt[FADE_SCREEN_OPTION_MINIMIZE_OPEN_CLOSE].value.b)
+	    if (fs->suppressMinimizeOpenClose)
 		break;
 
 	    if (w->texture->pixmap && matchEval (&fs->match, w))
@@ -442,8 +440,7 @@ fadeHandleEvent (CompDisplay *d,
 
 	    fw->shaded = w->shaded;
 
-	    if (fs->suppressMinimizeOpenClose ||
-		!fs->opt[FADE_SCREEN_OPTION_MINIMIZE_OPEN_CLOSE].value.b)
+	    if (fs->suppressMinimizeOpenClose)
 		break;
 
 	    if (!fw->shaded && w->texture->pixmap && matchEval (&fs->match, w))
@@ -468,8 +465,7 @@ fadeHandleEvent (CompDisplay *d,
 	{
 	    FADE_SCREEN(w->screen);
 
-	    if (fs->suppressMinimizeOpenClose ||
-		!fs->opt[FADE_SCREEN_OPTION_MINIMIZE_OPEN_CLOSE].value.b)
+	    if (fs->suppressMinimizeOpenClose)
 		break;
 
 	    fadeWindowStop (w);
@@ -604,8 +600,7 @@ fadeDamageWindowRect (CompWindow *w,
 	}
 	else if (matchEval (&fs->match, w))
 	{
-	    if (!fs->suppressMinimizeOpenClose &&
-		fs->opt[FADE_SCREEN_OPTION_MINIMIZE_OPEN_CLOSE].value.b)
+	    if (!fs->suppressMinimizeOpenClose)
 	    {
 		fw->opacity = 0;
 	    }
@@ -716,8 +711,7 @@ static const CompMetadataOptionInfo fadeScreenOptionInfo[] = {
     { "fade_speed", "float", "<min>0.1</min>", 0, 0 },
     { "window_match", "match", "<helper>true</helper>", 0, 0 },
     { "visual_bell", "bool", 0, 0, 0 },
-    { "fullscreen_visual_bell", "bool", 0, 0, 0 },
-    { "minimize_open_close", "bool", 0, 0, 0 }
+    { "fullscreen_visual_bell", "bool", 0, 0, 0 }
 };
 
 static Bool
-- 
1.4.4.2


More information about the compiz mailing list