Added border_inner_margin and border_outer_margin.
authorBrenden Matthews <brenden@rty.ca>
Fri, 12 Jun 2009 01:07:21 +0000 (19:07 -0600)
committerBrenden Matthews <brenden@rty.ca>
Fri, 12 Jun 2009 01:07:21 +0000 (19:07 -0600)
The border_margin config option is now deprecated.  This also resolves
an issue with weird border_margin values causing X to crash.

ChangeLog
doc/config_settings.xml
extras/nano/conky.nanorc
extras/vim/syntax/conkyrc.vim
src/conky.c

index a8c6166..a4f2d3b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-06-11
+       * Added border_inner_margin and border_outer_margin config options, and
+       deprecated border_margin
+
 2009-06-10
        * Fix regression with loading of non-Xft fonts (sf.net #2804324)
 
index ecb2218..fc5f8c1 100644 (file)
     <varlistentry>
         <term>
             <command>
-                <option>border_margin</option>
+                <option>border_inner_margin</option>
             </command>
         </term>
-        <listitem>Border margin in pixels. 
+        <listitem>Inner border margin in pixels (the margin between
+        the border and text). 
+        <para /></listitem>
+    </varlistentry>
+    <varlistentry>
+        <term>
+            <command>
+                <option>border_outer_margin</option>
+            </command>
+        </term>
+        <listitem>Outer border margin in pixels (the margin between
+        the border and the edge of the window). 
         <para /></listitem>
     </varlistentry>
     <varlistentry>
index d4acdc4..c16d40d 100644 (file)
@@ -5,7 +5,7 @@
 syntax "conky" "(\.*conkyrc.*$|conky.conf)"
 
 ## Configuration items
-color green "\<(alias|alignment|append_file|background|border_margin|border_width|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|colorN|cpu_avg_samples|default_bar_size|default_color|default_gauge_size|default_graph_size|default_outline_color|default_shade_color|diskio_avg_samples|display|double_buffer|draw_borders|draw_graph_borders|draw_outline|draw_shades|font|format_human_readable|gap_x|gap_y|if_up_strictness|imap|imlib_cache_flush_interval|imlib_cache_size|lua_load|mail_spool|max_port_monitor_connections|max_specials|max_user_text|maximum_width|minimum_size|mpd_host|mpd_password|mpd_port|music_player_interval|net_avg_samples|no_buffers|out_to_console|out_to_stderr|out_to_x|override_utf8_locale|overwrite_file|own_window|own_window_class|own_window_colour|own_window_hints|own_window_title|own_window_transparent|own_window_type|pad_percents|pop3|sensor_device|short_units|show_graph_range|show_graph_scale|stippled_borders|temperature_unit|template|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|text|text_buffer_size|top_cpu_separate|top_name_width|total_run_times|update_interval|uppercase|use_spacer|use_xft|xftalpha|xftfont)\>"
+color green "\<(alias|alignment|append_file|background|border_inner_margin|border_margin|border_outer_margin|border_width|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|colorN|cpu_avg_samples|default_bar_size|default_color|default_gauge_size|default_graph_size|default_outline_color|default_shade_color|diskio_avg_samples|display|double_buffer|draw_borders|draw_graph_borders|draw_outline|draw_shades|font|format_human_readable|gap_x|gap_y|if_up_strictness|imap|imlib_cache_flush_interval|imlib_cache_size|lua_load|mail_spool|max_port_monitor_connections|max_specials|max_user_text|maximum_width|minimum_size|mpd_host|mpd_password|mpd_port|music_player_interval|net_avg_samples|no_buffers|out_to_console|out_to_stderr|out_to_x|override_utf8_locale|overwrite_file|own_window|own_window_class|own_window_colour|own_window_hints|own_window_title|own_window_transparent|own_window_type|pad_percents|pop3|sensor_device|short_units|show_graph_range|show_graph_scale|stippled_borders|temperature_unit|template|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|text|text_buffer_size|top_cpu_separate|top_name_width|total_run_times|update_interval|uppercase|use_spacer|use_xft|xftalpha|xftfont)\>"
 
 ## Configuration item constants
 color yellow "\<(above|below|bottom_left|bottom_right|bottom_middle|desktop|dock|no|none|normal|override|skip_pager|skip_taskbar|sticky|top_left|top_right|top_middle|middle_left|middle_right|undecorated|yes)\>"
index 30436df..323f207 100644 (file)
@@ -12,7 +12,7 @@ endif
 
 syn region ConkyrcComment start=/^\s*#/ end=/$/
 
-syn keyword ConkyrcSetting alias alignment append_file background border_margin border_width color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 colorN cpu_avg_samples default_bar_size default_color default_gauge_size default_graph_size default_outline_color default_shade_color diskio_avg_samples display double_buffer draw_borders draw_graph_borders draw_outline draw_shades font format_human_readable gap_x gap_y if_up_strictness imap imlib_cache_flush_interval imlib_cache_size lua_load mail_spool max_port_monitor_connections max_specials max_user_text maximum_width minimum_size mpd_host mpd_password mpd_port music_player_interval net_avg_samples no_buffers out_to_console out_to_stderr out_to_x override_utf8_locale overwrite_file own_window own_window_class own_window_colour own_window_hints own_window_title own_window_transparent own_window_type pad_percents pop3 sensor_device short_units show_graph_range show_graph_scale stippled_borders temperature_unit template template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 text text_buffer_size top_cpu_separate top_name_width total_run_times update_interval uppercase use_spacer use_xft xftalpha xftfont
+syn keyword ConkyrcSetting alias alignment append_file background border_inner_margin border_margin border_outer_margin border_width color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 colorN cpu_avg_samples default_bar_size default_color default_gauge_size default_graph_size default_outline_color default_shade_color diskio_avg_samples display double_buffer draw_borders draw_graph_borders draw_outline draw_shades font format_human_readable gap_x gap_y if_up_strictness imap imlib_cache_flush_interval imlib_cache_size lua_load mail_spool max_port_monitor_connections max_specials max_user_text maximum_width minimum_size mpd_host mpd_password mpd_port music_player_interval net_avg_samples no_buffers out_to_console out_to_stderr out_to_x override_utf8_locale overwrite_file own_window own_window_class own_window_colour own_window_hints own_window_title own_window_transparent own_window_type pad_percents pop3 sensor_device short_units show_graph_range show_graph_scale stippled_borders temperature_unit template template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 text text_buffer_size top_cpu_separate top_name_width total_run_times update_interval uppercase use_spacer use_xft xftalpha xftfont
 
 syn keyword ConkyrcConstant
                        \ above
index 8482bda..1ad691b 100644 (file)
@@ -318,7 +318,7 @@ static int stippled_borders;
 
 static int draw_shades, draw_outline;
 
-static int border_margin, border_width;
+static long border_inner_margin, border_outer_margin, border_width;
 
 static long default_fg_color, default_bg_color, default_out_color;
 
@@ -5996,10 +5996,10 @@ static void update_text_area(void)
        if (own_window && !fixed_pos) {
                x += workarea[0];
                y += workarea[1];
-               text_start_x = border_margin + 1;
-               text_start_y = border_margin + 1;
-               window.x = x - border_margin - 1;
-               window.y = y - border_margin - 1;
+               text_start_x = border_inner_margin + border_outer_margin + border_width;
+               text_start_y = border_inner_margin + border_outer_margin + border_width;
+               window.x = x - border_inner_margin - border_outer_margin - border_width;
+               window.y = y - border_inner_margin - border_outer_margin - border_width;
        } else
 #endif
        {
@@ -6568,17 +6568,17 @@ static void draw_line(char *s)
 
                                case ALIGNR:
                                {
-                                       /* TODO: add back in "+ border_margin" to the end of
+                                       /* TODO: add back in "+ border_inner_margin" to the end of
                                         * this line? */
                                        int pos_x = text_start_x + text_width -
                                                get_string_width_special(s);
 
                                        /* printf("pos_x %i text_start_x %i text_width %i cur_x %i "
                                                "get_string_width(p) %i gap_x %i "
-                                               "specials[special_index].arg %i border_margin %i "
+                                               "specials[special_index].arg %i border_inner_margin %i "
                                                "border_width %i\n", pos_x, text_start_x, text_width,
                                                cur_x, get_string_width_special(s), gap_x,
-                                               specials[special_index].arg, border_margin,
+                                               specials[special_index].arg, border_inner_margin,
                                                border_width); */
                                        if (pos_x > specials[special_index].arg && pos_x > cur_x) {
                                                cur_x = pos_x - specials[special_index].arg;
@@ -6630,8 +6630,6 @@ static void draw_text(void)
 
                /* draw borders */
                if (draw_borders && border_width > 0) {
-                       unsigned int b = (border_width + 1) / 2;
-
                        if (stippled_borders) {
                                char ss[2] = { stippled_borders, stippled_borders };
                                XSetLineAttributes(display, window.gc, border_width, LineOnOffDash,
@@ -6643,9 +6641,10 @@ static void draw_text(void)
                        }
 
                        XDrawRectangle(display, window.drawable, window.gc,
-                               text_start_x - border_margin + b, text_start_y - border_margin + b,
-                               text_width + border_margin * 2 - 1 - b * 2,
-                               text_height + border_margin * 2 - 1 - b * 2);
+                               text_start_x - border_inner_margin - border_width,
+                               text_start_y - border_inner_margin - border_width,
+                               text_width + border_inner_margin * 2 + border_width * 2,
+                               text_height + border_inner_margin * 2 + border_width * 2);
                }
 
                /* draw text */
@@ -6740,10 +6739,10 @@ static void clear_text(int exposures)
 #endif
        if (display && window.window) { // make sure these are !null
                /* there is some extra space for borders and outlines */
-               XClearArea(display, window.window, text_start_x - border_margin - 1,
-                       text_start_y - border_margin - 1,
-                       text_width + border_margin * 2 + 2,
-                       text_height + border_margin * 2 + 2, exposures ? True : 0);
+               XClearArea(display, window.window, text_start_x - border_inner_margin - border_outer_margin - border_width,
+                       text_start_y - border_inner_margin - border_outer_margin - border_width,
+                       text_width + border_inner_margin * 2 + border_outer_margin * 2 + border_width * 2,
+                       text_height + border_inner_margin * 2 + border_outer_margin * 2 + border_width * 2, exposures ? True : 0);
        }
 }
 #endif /* X11 */
@@ -6851,10 +6850,10 @@ static void main_loop(void)
                                if (own_window) {
                                        /* resize window if it isn't right size */
                                        if (!fixed_size
-                                               && (text_width + border_margin * 2 + 1 != window.width
-                                               || text_height + border_margin * 2 + 1 != window.height)) {
-                                                       window.width = text_width + border_margin * 2 + 1;
-                                                       window.height = text_height + border_margin * 2 + 1;
+                                               && (text_width + border_inner_margin * 2 + border_outer_margin * 2 + border_width * 2 + 1 != window.width
+                                               || text_height + border_inner_margin * 2 + border_outer_margin * 2 + border_width * 2 + 1 != window.height)) {
+                                                       window.width = text_width + border_inner_margin * 2 + border_outer_margin * 2 + border_width * 2 + 1;
+                                                       window.height = text_height + border_inner_margin * 2 + border_outer_margin * 2 + border_width * 2 + 1;
                                                        XResizeWindow(display, window.window, window.width,
                                                                window.height);
                                                        if (own_window) {
@@ -6875,10 +6874,10 @@ static void main_loop(void)
                                if (use_xdbe) {
                                        XRectangle r;
 
-                                       r.x = text_start_x - border_margin;
-                                       r.y = text_start_y - border_margin;
-                                       r.width = text_width + border_margin * 2;
-                                       r.height = text_height + border_margin * 2;
+                                       r.x = text_start_x - border_inner_margin - border_outer_margin - border_width;
+                                       r.y = text_start_y - border_inner_margin - border_outer_margin - border_width;
+                                       r.width = text_width + border_inner_margin * 2 + border_outer_margin * 2 + border_width * 2;
+                                       r.height = text_height + border_inner_margin * 2 + border_outer_margin * 2 + border_width * 2;
                                        XUnionRectWithRegion(&r, x11_stuff.region, x11_stuff.region);
                                }
 #endif
@@ -6931,8 +6930,8 @@ static void main_loop(void)
                                                                        }
                                                                }
 
-                                                               text_width = window.width - border_margin * 2 - 1;
-                                                               text_height = window.height - border_margin * 2 - 1;
+                                                               text_width = window.width - border_inner_margin * 2 - border_outer_margin * 2 - border_width * 2;
+                                                               text_height = window.height - border_inner_margin * 2 - border_outer_margin * 2 - border_width * 2;
                                                                if (text_width > maximum_width
                                                                                && maximum_width > 0) {
                                                                        text_width = maximum_width;
@@ -7026,10 +7025,10 @@ static void main_loop(void)
                                if (use_xdbe) {
                                        XRectangle r;
 
-                                       r.x = text_start_x - border_margin;
-                                       r.y = text_start_y - border_margin;
-                                       r.width = text_width + border_margin * 2;
-                                       r.height = text_height + border_margin * 2;
+                                       r.x = text_start_x - border_inner_margin - border_outer_margin - border_width;
+                                       r.y = text_start_y - border_inner_margin - border_outer_margin - border_width;
+                                       r.width = text_width + border_inner_margin * 2 + border_outer_margin * 2 + border_width * 2;
+                                       r.height = text_height + border_inner_margin * 2 + border_outer_margin * 2 + border_width * 2;
                                        XUnionRectWithRegion(&r, x11_stuff.region, x11_stuff.region);
                                }
 #endif
@@ -7462,7 +7461,8 @@ static void set_default_configurations(void)
        sprintf(window.title, PACKAGE_NAME" (%s)", info.uname_s.nodename);
 #endif
        stippled_borders = 0;
-       border_margin = 3;
+       border_inner_margin = 3;
+       border_outer_margin = 1;
        border_width = 1;
        text_alignment = BOTTOM_LEFT;
        info.x11.monitor.number = 1;
@@ -7588,12 +7588,12 @@ static void X11_create_window(void)
 {
        if (output_methods & TO_X) {
 #ifdef OWN_WINDOW
-               init_window(own_window, text_width + border_margin * 2 + 1,
-                               text_height + border_margin * 2 + 1, set_transparent, background_colour,
+               init_window(own_window, text_width + border_inner_margin * 2 + border_outer_margin * 2 + border_width * 2 + 1,
+                               text_height + border_inner_margin * 2 + border_outer_margin * 2 + border_width * 2 + 1, set_transparent, background_colour,
                                xargv, xargc);
 #else /* OWN_WINDOW */
-               init_window(0, text_width + border_margin * 2 + 1,
-                               text_height + border_margin * 2 + 1, set_transparent, 0,
+               init_window(0, text_width + border_inner_margin * 2 + border_outer_margin * 2 + border_width * 2 + 1,
+                               text_height + border_inner_margin * 2 + border_outer_margin * 2 + border_width * 2 + 1, set_transparent, 0,
                                xargv, xargc);
 #endif /* OWN_WINDOW */
 
@@ -7776,8 +7776,20 @@ static void load_config_file(const char *f)
                        show_graph_range = string_to_bool(value);
                }
                CONF("border_margin") {
+                       ERR("border_margin is deprecated, please use border_inner_margin instead");
+               }
+               CONF("border_inner_margin") {
+                       if (value) {
+                               border_inner_margin = strtol(value, 0, 0);
+                               if (border_inner_margin < 0) border_inner_margin = 0;
+                       } else {
+                               CONF_ERR;
+                       }
+               }
+               CONF("border_outer_margin") {
                        if (value) {
-                               border_margin = strtol(value, 0, 0);
+                               border_outer_margin = strtol(value, 0, 0);
+                               if (border_outer_margin < 0) border_outer_margin = 0;
                        } else {
                                CONF_ERR;
                        }
@@ -7785,6 +7797,7 @@ static void load_config_file(const char *f)
                CONF("border_width") {
                        if (value) {
                                border_width = strtol(value, 0, 0);
+                               if (border_width < 0) border_width = 0;
                        } else {
                                CONF_ERR;
                        }