To illustrate my answer, i rebuilt decoration-opacity patch, you can
with this one, set default alpha decoration with decoration_opacity
option. I also corrected create_pixmap function.
What do you think about it ?

Le lundi 02 octobre 2006 à 20:14 +0200, gandalfn a écrit :
> Le lundi 02 octobre 2006 à 12:42 -0400, David Reveman a écrit :
> > Hey,
> Hi,
> 
> > 
> > I assume that the new metacity theme version [1] will have full support
> > for alpha but it might make sense to add support for translucent
> > decorations to old themes as well. We need to make sure that it doesn't
> > cause any issues with some themes though. It seems to me that it makes
> > more sense to have an overall opacity setting that can be used to adjust
> > how translucent the decorations should be. That can be implemented in
> > such a way that we can be sure that it doesn't cause issues with some
> > old themes. What do you think?
> > 
> For the moment I think too that the better solution would be to be able
> to adjust the alpha value which I regulated to zero per defect in my
> patch, to keep, as you suggest it, a compatibility with the old metacity
> themes while having translucent decorations.
> 
> > btw, is the changes to the create_pixmap function in your patch suppose
> > to be a cleanup? The changes makes it so it no longer fails when an ARGB
> > colormap can't be find and I'm not sure that's right.
> > 
> 
> Not indeed, that is not correct ! it's one of my bad programming habits,
> sorry.
> 
> 
> Ps: I hope that my english is correct and that you understand it :)
> 
> > -David
> > 
> > 
> > [1] http://bugzilla.gnome.org/show_bug.cgi?id=102547
> > 
> > 
> > 
> > On Sun, 2006-10-01 at 20:38 +0200, gandalfn wrote:
> > > hi,
> > > 
> > > I made a small a patch for gtk-window-decorator which define default
> > > border alpha to zero when it use metacity theme.
> > > That allows while playing with the alpha attributes of the metacity
> > > themes to have transparent borders. here too the modified “Human Ubuntu”
> > > theme and a screenshot to show the result.
> > > 
> > > ps: sorry for my bad english
> > > _______________________________________________
> > > compiz mailing list
> > > [email protected]
> > > http://lists.freedesktop.org/mailman/listinfo/compiz
> > 
> > 
> > �
> > 
> 
> _______________________________________________
> compiz mailing list
> [email protected]
> http://lists.freedesktop.org/mailman/listinfo/compiz
> �
> 
diff -ru compiz-freedesktop-0.2.0.save/gtk/window-decorator/gtk-window-decorator.c compiz-freedesktop-0.2.0/gtk/window-decorator/gtk-window-decorator.c
--- compiz-freedesktop-0.2.0.save/gtk/window-decorator/gtk-window-decorator.c	2006-10-02 18:24:17.000000000 +0200
+++ compiz-freedesktop-0.2.0/gtk/window-decorator/gtk-window-decorator.c	2006-10-02 23:23:12.000000000 +0200
@@ -88,6 +88,9 @@
 #define COMPIZ_SHADOW_OFFSET_Y_KEY \
     COMPIZ_GCONF_DIR1 "/shadow_offset_y"
 
+#define COMPIZ_DECORATION_OPACITY_KEY \
+    COMPIZ_GCONF_DIR1 "/decoration_opacity"
+
 #define META_AUDIBLE_BELL_KEY	       \
     METACITY_GCONF_DIR "/audible_bell"
 
@@ -161,6 +164,8 @@
 #define WM_MOVERESIZE_SIZE_KEYBOARD     9
 #define WM_MOVERESIZE_MOVE_KEYBOARD    10
 
+#define DECORATION_OPACITY 1.0
+
 #define SHADOW_RADIUS   8.0
 #define SHADOW_OPACITY  0.5
 #define SHADOW_OFFSET_X 1
@@ -246,6 +251,8 @@
 static gint shadow_top_corner_space    = 0;
 static gint shadow_bottom_corner_space = 0;
 
+static gdouble decoration_opacity = DECORATION_OPACITY;
+
 static gdouble shadow_radius   = SHADOW_RADIUS;
 static gdouble shadow_opacity  = SHADOW_OPACITY;
 static gint    shadow_offset_x = SHADOW_OFFSET_X;
@@ -2117,7 +2124,8 @@
 
     region = meta_get_window_region (&fgeom, clip.width, clip.height);
 
-    gdk_cairo_set_source_color (cr, &style->bg[GTK_STATE_NORMAL]);
+    gdk_cairo_set_source_color_alpha (cr, &style->bg[GTK_STATE_NORMAL], 
+                                      decoration_opacity);
 
     for (i = 0; i < region->numRects; i++)
     {
@@ -2497,6 +2505,7 @@
     GdkPixmap	*pixmap;
     GdkVisual	*visual;
     GdkColormap *colormap;
+    GdkScreen * screen;
 
     visual = gdk_visual_get_best_with_depth (32);
     if (!visual)
@@ -2506,15 +2515,13 @@
     if (!pixmap)
 	return NULL;
 
-    colormap = gdk_colormap_new (visual, FALSE);
+    screen = gdk_visual_get_screen(visual);
+
+    colormap = gdk_screen_get_rgba_colormap(screen);
     if (!colormap)
-    {
-	gdk_pixmap_unref (pixmap);
-	return NULL;
-    }
+        return NULL;
 
     gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap), colormap);
-    gdk_colormap_unref (colormap);
 
     return pixmap;
 }
@@ -5734,6 +5741,24 @@
 }
 
 static gboolean
+decoration_opacity_changed (GConfClient *client)
+{
+    double   opacity;
+    gboolean changed = FALSE;
+
+    opacity = gconf_client_get_float (client,
+				      COMPIZ_DECORATION_OPACITY_KEY,
+				      NULL);
+    if (decoration_opacity != opacity)
+    {
+	decoration_opacity = opacity;
+	return TRUE;
+    }
+    
+    return FALSE;
+}
+
+static gboolean
 shadow_settings_changed (GConfClient *client)
 {
     double   radius, opacity;
@@ -5917,6 +5942,11 @@
 	if (shadow_settings_changed (client))
 	    changed = TRUE;
     }
+    else if (strcmp (key, COMPIZ_DECORATION_OPACITY_KEY) == 0)
+    {
+        if (decoration_opacity_changed(client))
+	    changed = TRUE;
+    }
     else if (strcmp (key, META_AUDIBLE_BELL_KEY)     == 0 ||
 	     strcmp (key, META_VISUAL_BELL_KEY)      == 0 ||
 	     strcmp (key, META_VISUAL_BELL_TYPE_KEY) == 0)
@@ -6040,6 +6070,7 @@
     titlebar_font_changed (gconf);
     update_titlebar_font ();
     double_click_titlebar_changed (gconf);
+    decoration_opacity_changed (gconf);
     shadow_settings_changed (gconf);
     bell_settings_changed (gconf);
     update_shadow ();
diff -ru compiz-freedesktop-0.2.0.save/plugins/compiz.schemas.in compiz-freedesktop-0.2.0/plugins/compiz.schemas.in
--- compiz-freedesktop-0.2.0.save/plugins/compiz.schemas.in	2006-10-02 05:05:28.000000000 +0200
+++ compiz-freedesktop-0.2.0/plugins/compiz.schemas.in	2006-10-02 23:27:06.000000000 +0200
@@ -11689,6 +11689,18 @@
         </schema>
 
         <schema>
+            <key>/schemas/apps/compiz/plugins/decoration/allscreens/options/decoration_opacity</key>
+            <applyto>/apps/compiz/plugins/decoration/allscreens/options/decoration_opacity</applyto>
+            <owner>compiz</owner>
+            <type>float</type>
+            <default>1.000000</default>
+            <locale name="C">
+                <short>Decoration Opacity</short>
+                <long>Decoration opacity (0.0-1.0)</long>
+            </locale>
+        </schema>
+        
+	<schema>
             <key>/schemas/apps/compiz/plugins/decoration/allscreens/options/shadow_radius</key>
             <applyto>/apps/compiz/plugins/decoration/allscreens/options/shadow_radius</applyto>
             <owner>compiz</owner>
_______________________________________________
compiz mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/compiz

Reply via email to