Add option to fix the size of rofi

This commit is contained in:
QC 2014-05-17 22:17:07 +02:00
parent 08da286931
commit f44fd74987
4 changed files with 26 additions and 16 deletions

View File

@ -69,5 +69,6 @@ Settings config = {
.padding = 5,
.show_title = 1,
.y_offset = 0,
.x_offset = 0
.x_offset = 0,
.fixed_num_lines = 0
};

View File

@ -105,6 +105,7 @@ typedef struct _Settings
int x_offset;
unsigned int show_title;
unsigned int fixed_num_lines;
} Settings;

View File

@ -1031,8 +1031,14 @@ MenuReturn menu ( char **lines, char **input, char *prompt, Time *time, int *shi
;
}
unsigned int max_lines = MIN ( config.menu_lines, num_lines );
if ( config.fixed_num_lines == 1 )
{
max_lines = config.menu_lines;
}
// Calculate as float to stop silly, big rounding down errors.
int w = config.menu_width < 101 ? ( mon.w / 100.0f ) * ( float ) config.menu_width : config.menu_width;
int x = mon.x + ( mon.w - w ) / 2;
@ -1184,6 +1190,7 @@ MenuReturn menu ( char **lines, char **input, char *prompt, Time *time, int *shi
// Subtract the margin of the last row.
int h = line_height * ( max_lines + 1 ) + ( config.padding ) * 2 + LINE_MARGIN;
if ( config.wmode == HORIZONTAL )
{
h = line_height + ( config.padding ) * 2;

View File

@ -51,21 +51,22 @@ typedef struct
};
} XrmOption;
XrmOption xrmOptions[] = {
{ xrm_Number, "opacity", { .num = &config.window_opacity } },
{ xrm_Number, "width", { .num = &config.menu_width } },
{ xrm_Number, "lines", { .num = &config.menu_lines } },
{ xrm_String, "font", { .str = &config.menu_font } },
{ xrm_String, "foreground", { .str = &config.menu_fg } },
{ xrm_String, "background", { .str = &config.menu_bg } },
{ xrm_String, "highlightfg", { .str = &config.menu_hlfg } },
{ xrm_String, "highlightbg", { .str = &config.menu_hlbg } },
{ xrm_String, "bordercolor", { .str = &config.menu_bc } },
{ xrm_Number, "padding", { .num = &config.padding } },
{ xrm_Number, "borderwidth", { .num = &config.menu_bw } },
{ xrm_String, "terminal", { .str = &config.terminal_emulator } },
{ xrm_Number, "location", { .num = &config.location } },
{ xrm_Number, "yoffset", { .num = &config.y_offset } },
{ xrm_Number, "xoffset", { .num = &config.x_offset } },
{ xrm_Number, "opacity", { .num = &config.window_opacity } },
{ xrm_Number, "width", { .num = &config.menu_width } },
{ xrm_Number, "lines", { .num = &config.menu_lines } },
{ xrm_String, "font", { .str = &config.menu_font } },
{ xrm_String, "foreground", { .str = &config.menu_fg } },
{ xrm_String, "background", { .str = &config.menu_bg } },
{ xrm_String, "highlightfg", { .str = &config.menu_hlfg } },
{ xrm_String, "highlightbg", { .str = &config.menu_hlbg } },
{ xrm_String, "bordercolor", { .str = &config.menu_bc } },
{ xrm_Number, "padding", { .num = &config.padding } },
{ xrm_Number, "borderwidth", { .num = &config.menu_bw } },
{ xrm_String, "terminal", { .str = &config.terminal_emulator } },
{ xrm_Number, "location", { .num = &config.location } },
{ xrm_Number, "yoffset", { .num = &config.y_offset } },
{ xrm_Number, "xoffset", { .num = &config.x_offset } },
{ xrm_Number, "fixed_num_lines", { .num = &config.fixed_num_lines } },
};