[Xfce4-commits] <xfce4-notifyd:master> Respect border-width when drawing the notification (bug #9475).

Jérôme Guelfucci noreply at xfce.org
Sat Jan 12 17:56:01 CET 2013


Updating branch refs/heads/master
         to d9ab1de0f0d0d5e44a777b80e3b68f738dc5a04d (commit)
       from 03e18b4a8bf1feb21ef55750c26610724bc59094 (commit)

commit d9ab1de0f0d0d5e44a777b80e3b68f738dc5a04d
Author: Dinkel <dinkel at pimprecords.com>
Date:   Sat Jan 12 17:51:42 2013 +0100

    Respect border-width when drawing the notification (bug #9475).
    
    Add a border-width / 2 padding when drawing so that the whole border is
    drawable in the drawing area. Previously big border values would cause
    only half of the border to be drawn.

 NEWS                               |    1 +
 xfce4-notifyd/xfce-notify-window.c |   45 ++++++++++++++++++++++++------------
 2 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/NEWS b/NEWS
index fd5d2eb..2165537 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,7 @@ Version 0.2.3git:
     * Parse body with g_markup_escape_text which allows us to handle
       span attributes missused by some clients and to parse strings with
       "unusual" caracters such as & (bug #7773, #8187).
+    * Respect border-width when drawing the notification (bug #9475).
 
 Version 0.2.2 (06 August 2011):
 
diff --git a/xfce4-notifyd/xfce-notify-window.c b/xfce4-notifyd/xfce-notify-window.c
index 0459f40..bf307da 100644
--- a/xfce4-notifyd/xfce-notify-window.c
+++ b/xfce4-notifyd/xfce-notify-window.c
@@ -399,6 +399,12 @@ xfce_notify_window_ensure_bg_path(XfceNotifyWindow *window,
 {
     GtkWidget *widget = GTK_WIDGET(window);
     gdouble radius = DEFAULT_RADIUS;
+    gdouble border_width = DEFAULT_BORDER_WIDTH;
+
+    /* this secifies the padding from the edges in order to make
+     * sure the border completely fits into the drawing area */
+    gdouble padding = 0.0;
+
     cairo_path_t *flat_path;
     GdkRegion *region;
     GdkFillRule fill_rule;
@@ -411,24 +417,27 @@ xfce_notify_window_ensure_bg_path(XfceNotifyWindow *window,
 
     gtk_widget_style_get(widget,
                          "border-radius", &radius,
+                         "border-width", &border_width,
                          NULL);
 
+    padding = border_width / 2.0;
+
     if(radius < 0.1) {
         cairo_rectangle(cr, 0, 0, widget->allocation.width,
                         widget->allocation.height);
     } else {
-        cairo_move_to(cr, 0, radius);
-        cairo_arc(cr, radius, radius, radius, M_PI, 3.0*M_PI/2.0);
-        cairo_line_to(cr, widget->allocation.width - radius, 0);
-        cairo_arc(cr, widget->allocation.width - radius, radius, radius,
+        cairo_move_to(cr, padding, radius + padding);
+        cairo_arc(cr, radius + padding, radius + padding, radius, M_PI, 3.0*M_PI/2.0);
+        cairo_line_to(cr, widget->allocation.width - radius - padding, padding);
+        cairo_arc(cr, widget->allocation.width - radius - padding, radius + padding, radius,
                   3.0*M_PI/2.0, 0.0);
-        cairo_line_to(cr, widget->allocation.width,
-                      widget->allocation.height - radius);
-        cairo_arc(cr, widget->allocation.width - radius,
-                  widget->allocation.height - radius, radius,
+        cairo_line_to(cr, widget->allocation.width - padding,
+                      widget->allocation.height - radius - padding);
+        cairo_arc(cr, widget->allocation.width - radius - padding,
+                  widget->allocation.height - radius - padding, radius,
                   0.0, M_PI/2.0);
-        cairo_line_to(cr, radius, widget->allocation.height);
-        cairo_arc(cr, radius, widget->allocation.height - radius, radius,
+        cairo_line_to(cr, radius + padding, widget->allocation.height - padding);
+        cairo_arc(cr, radius + padding, widget->allocation.height - radius - padding, radius,
                   M_PI/2.0, M_PI);
         cairo_close_path(cr);
     }
@@ -503,11 +512,17 @@ xfce_notify_window_expose(GtkWidget *widget,
         GdkColor *border_color = NULL;
         gdouble border_width = DEFAULT_BORDER_WIDTH;
 
+        /* this secifies the padding from the edges in order to make sure the
+         * border completely fits into the dranwing area */
+        gdouble padding = 0.0;
+
         gtk_widget_style_get(widget,
                              "border-color", &border_color,
                              "border-width", &border_width,
                              NULL);
 
+        padding = border_width / 2.0;
+
         cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
         if(border_color)
             gdk_cairo_set_source_color(cr, border_color);
@@ -522,7 +537,7 @@ xfce_notify_window_expose(GtkWidget *widget,
             cairo_path_t *flat_path;
             GdkFillRule fill_rule;
 
-            cairo_arc(cr, widget->allocation.width - 12., 12., 7.5, 0., 2*M_PI);
+            cairo_arc(cr, widget->allocation.width - 12.0 - padding, 12.0 + padding, 7.5, 0., 2*M_PI);
             window->close_btn_path = cairo_copy_path(cr);
 
             flat_path = cairo_copy_path_flat(cr);
@@ -536,11 +551,11 @@ xfce_notify_window_expose(GtkWidget *widget,
         cairo_set_line_width(cr, 1.5);
         cairo_stroke(cr);
 
-        cairo_move_to(cr, widget->allocation.width - 8., 8.);
-        cairo_line_to(cr, widget->allocation.width - 16., 16.);
+        cairo_move_to(cr, widget->allocation.width - 8.0 - padding, 8.0 + padding);
+        cairo_line_to(cr, widget->allocation.width - 16.0 - padding, 16.0 + padding);
         cairo_stroke(cr);
-        cairo_move_to(cr, widget->allocation.width - 16., 8.);
-        cairo_line_to(cr, widget->allocation.width - 8., 16.);
+        cairo_move_to(cr, widget->allocation.width - 16.0 - padding, 8.0 + padding);
+        cairo_line_to(cr, widget->allocation.width - 8.0 - padding, 16.0 + padding);
         cairo_stroke(cr);
     }
 


More information about the Xfce4-commits mailing list