all repos — openbox @ 5f963a1fbc792700a1f51aa9340464aedf97db97

openbox fork - make it a bit more like ryudo

READ_INT macro.
Dave Foster daf@minuslab.net
commit

5f963a1fbc792700a1f51aa9340464aedf97db97

parent

27ae9d65c838478f1c7e07ec52a6848600865bf1

1 files changed, 20 insertions(+), 45 deletions(-)

jump to
M obrender/theme.cobrender/theme.c

@@ -63,6 +63,11 @@ return *default_font;

} } +#define READ_INT(x_resstr, x_var, x_min, x_max, x_def) \ + if (!read_int(db, x_resstr, & x_var) || \ + x_var < x_min || x_var > x_max) \ + x_var = x_def; + RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name, gboolean allow_fallback, RrFont *active_window_font, RrFont *inactive_window_font,

@@ -178,51 +183,21 @@ theme->osd_font_hilite = get_font(active_osd_font, &default_font, inst);

theme->osd_font_unhilite = get_font(inactive_osd_font, &default_font,inst); /* load direct dimensions */ - if ((!read_int(db, "menu.overlap.x", &theme->menu_overlap_x) && - !read_int(db, "menu.overlap", &theme->menu_overlap_x)) || - theme->menu_overlap_x < -100 || theme->menu_overlap_x > 100) - theme->menu_overlap_x = 0; - if ((!read_int(db, "menu.overlap.y", &theme->menu_overlap_y) && - !read_int(db, "menu.overlap", &theme->menu_overlap_y)) || - theme->menu_overlap_y < -100 || theme->menu_overlap_y > 100) - theme->menu_overlap_y = 0; - if (!read_int(db, "window.handle.width", &theme->handle_height) || - theme->handle_height < 0 || theme->handle_height > 100) - theme->handle_height = 6; - if (!read_int(db, "padding.width", &theme->paddingx) || - theme->paddingx < 0 || theme->paddingx > 100) - theme->paddingx = 3; - if (!read_int(db, "padding.height", &theme->paddingy) || - theme->paddingy < 0 || theme->paddingy > 100) - theme->paddingy = theme->paddingx; - if (!read_int(db, "border.width", &theme->fbwidth) || - theme->fbwidth < 0 || theme->fbwidth > 100) - theme->fbwidth = 1; - /* menu border width inherits from the frame border width */ - if (!read_int(db, "menu.border.width", &theme->mbwidth) || - theme->mbwidth < 0 || theme->mbwidth > 100) - theme->mbwidth = theme->fbwidth; - /* osd border width inherits from the frame border width */ - if (!read_int(db, "osd.border.width", &theme->obwidth) || - theme->obwidth < 0 || theme->obwidth > 100) - theme->obwidth = theme->fbwidth; - if (!read_int(db, "window.client.padding.width", &theme->cbwidthx) || - theme->cbwidthx < 0 || theme->cbwidthx > 100) - theme->cbwidthx = theme->paddingx; - if (!read_int(db, "window.client.padding.height", &theme->cbwidthy) || - theme->cbwidthy < 0 || theme->cbwidthy > 100) - theme->cbwidthy = theme->cbwidthx; - if (!read_int(db, "menu.separator.width", &theme->menu_sep_width) || - theme->menu_sep_width < 1 || theme->menu_sep_width > 100) - theme->menu_sep_width = 1; - if (!read_int(db, "menu.separator.padding.width", - &theme->menu_sep_paddingx) || - theme->menu_sep_paddingx < 0 || theme->menu_sep_paddingx > 100) - theme->menu_sep_paddingx = 6; - if (!read_int(db, "menu.separator.padding.height", - &theme->menu_sep_paddingy) || - theme->menu_sep_paddingy < 0 || theme->menu_sep_paddingy > 100) - theme->menu_sep_paddingy = 3; + + /* TODO: Need fallback for menu.overlap */ + READ_INT("menu.overlap.x", theme->menu_overlap_x, -100, 100, 0); + READ_INT("menu.overlap.y", theme->menu_overlap_y, -100, 100, 0); + READ_INT("window.handle.width", theme->handle_height, 0, 100, 6); + READ_INT("padding.width", theme->paddingx, 0, 100, 3); + READ_INT("padding.height", theme->paddingy, 0, 100, theme->paddingx); + READ_INT("border.width", theme->fbwidth, 0, 100, 1); + READ_INT("menu.border.width", theme->mbwidth, 0, 100, theme->fbwidth); + READ_INT("osd.border.width", theme->obwidth, 0, 100, theme->fbwidth); + READ_INT("window.client.padding.width", theme->cbwidthx, 0, 100, theme->paddingx); + READ_INT("window.client.padding.height", theme->cbwidthy, 0, 100, theme->cbwidthx); + READ_INT("menu.separator.width", theme->menu_sep_width, 1, 100, 1); + READ_INT("menu.separator.padding.width", theme->menu_sep_paddingx, 0, 100, 6); + READ_INT("menu.separator.padding.height", theme->menu_sep_paddingy, 0, 100, 3); /* load colors */ if (!read_color(db, inst,