]> Dogcows Code - chaz/openbox/blobdiff - render/font.c
Merge branch 'backport' into work
[chaz/openbox] / render / font.c
index e7cef6ab32854228465c2608b4c35f70b4a7008d..583c9f7d7af277b2986429a4036fabc38500f907 100644 (file)
@@ -148,11 +148,13 @@ static void font_measure_full(const RrFont *f, const gchar *str,
     if (flow) {
         pango_layout_set_single_paragraph_mode(f->layout, FALSE);
         pango_layout_set_width(f->layout, maxwidth * PANGO_SCALE);
+        pango_layout_set_ellipsize(f->layout, PANGO_ELLIPSIZE_NONE);
     }
     else {
         /* single line mode */
         pango_layout_set_single_paragraph_mode(f->layout, TRUE);
         pango_layout_set_width(f->layout, -1);
+        pango_layout_set_ellipsize(f->layout, PANGO_ELLIPSIZE_MIDDLE);
     }
 
     /* pango_layout_get_pixel_extents lies! this is the right way to get the
@@ -240,19 +242,23 @@ void RrFontDraw(XftDraw *d, RrTextureText *t, RrRect *area)
     w -= 4;
     h = area->height;
 
-    switch (t->ellipsize) {
-    case RR_ELLIPSIZE_NONE:
+    if (t->flow)
         ell = PANGO_ELLIPSIZE_NONE;
-        break;
-    case RR_ELLIPSIZE_START:
-        ell = PANGO_ELLIPSIZE_START;
-        break;
-    case RR_ELLIPSIZE_MIDDLE:
-        ell = PANGO_ELLIPSIZE_MIDDLE;
-        break;
-    case RR_ELLIPSIZE_END:
-        ell = PANGO_ELLIPSIZE_END;
-        break;
+    else {
+        switch (t->ellipsize) {
+        case RR_ELLIPSIZE_NONE:
+            ell = PANGO_ELLIPSIZE_NONE;
+            break;
+        case RR_ELLIPSIZE_START:
+            ell = PANGO_ELLIPSIZE_START;
+            break;
+        case RR_ELLIPSIZE_MIDDLE:
+            ell = PANGO_ELLIPSIZE_MIDDLE;
+            break;
+        case RR_ELLIPSIZE_END:
+            ell = PANGO_ELLIPSIZE_END;
+            break;
+        }
     }
 
     pango_layout_set_text(t->font->layout, t->string, -1);
@@ -279,9 +285,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;
 
This page took 0.024794 seconds and 4 git commands to generate.