make the internal window type more easily inheritable
[mikachu/openbox.git] / render / font.c
index a32bf7c..369f262 100644 (file)
@@ -244,7 +244,7 @@ void RrFontDraw(XftDraw *d, RrTextureText *t, RrRect *area)
     pango_layout_get_pixel_extents(t->font->layout, NULL, &rect);
     mw = rect.width;
 
-    /* pango_layout_set_alignment doesn't work with 
+    /* pango_layout_set_alignment doesn't work with
        pango_xft_render_layout_line */
     switch (t->justify) {
     case RR_JUSTIFY_LEFT:
@@ -258,9 +258,20 @@ void RrFontDraw(XftDraw *d, RrTextureText *t, RrRect *area)
     }
 
     if (t->shadow_offset_x || t->shadow_offset_y) {
-        c.color.red = t->shadow_color->r | t->shadow_color->r << 8;
-        c.color.green = t->shadow_color->g | t->shadow_color->g << 8;
-        c.color.blue = t->shadow_color->b | t->shadow_color->b << 8;
+        /* From nvidia's readme (chapter 23):
+
+           When rendering to a 32-bit window, keep in mind that the X RENDER
+           extension, used by most composite managers, expects "premultiplied
+           alpha" colors. This means that if your color has components (r,g,b)
+           and alpha value a, then you must render (a*r, a*g, a*b, a) into the
+           target window.
+        */
+        c.color.red = (t->shadow_color->r | t->shadow_color->r << 8) *
+            t->shadow_alpha / 255;
+        c.color.green = (t->shadow_color->g | t->shadow_color->g << 8) *
+            t->shadow_alpha / 255;
+        c.color.blue = (t->shadow_color->b | t->shadow_color->b << 8) *
+            t->shadow_alpha / 255;
         c.color.alpha = 0xffff * t->shadow_alpha / 255;
         c.pixel = t->shadow_color->pixel;
 
@@ -278,11 +289,11 @@ void RrFontDraw(XftDraw *d, RrTextureText *t, RrRect *area)
     c.pixel = t->color->pixel;
 
     if (t->shortcut) {
-        const gchar *c = t->string + t->shortcut_pos;
+        const gchar *s = t->string + t->shortcut_pos;
 
         t->font->shortcut_underline->start_index = t->shortcut_pos;
         t->font->shortcut_underline->end_index = t->shortcut_pos +
-            (g_utf8_next_char(c) - c);
+            (g_utf8_next_char(s) - s);
 
         /* the attributes are owned by the layout.
            re-add the attributes to the layout after changing the