1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-03 04:23:42 -05:00

Add hmode to xrmoptions.

This commit is contained in:
QC 2014-05-19 22:12:54 +02:00
parent 05cf49a880
commit 3157358c63
4 changed files with 18 additions and 11 deletions

View file

@ -68,7 +68,7 @@ Settings config = {
// Location of the window. WL_CENTER, WL_NORTH_WEST, WL_NORTH,WL_NORTH_EAST, etc.
.location = WL_CENTER,
// Mode of window, list (Vertical) or dmenu like (Horizontal)
.wmode = VERTICAL,
.hmode = VERTICAL,
// Padding of the window.
.padding = 5,
.show_title = 1,
@ -105,4 +105,10 @@ void config_sanity_check( void )
WL_WEST, config.location, WL_CENTER);
exit(1);
}
if ( !( config.hmode == VERTICAL || config.hmode == HORIZONTAL ) )
{
fprintf(stderr, "config.hmode is invalid.\n");
exit(1);
}
}

View file

@ -91,7 +91,7 @@ typedef struct _Settings
char * run_key;
char * ssh_key;
WindowLocation location;
WindowMode wmode;
WindowMode hmode;
unsigned int padding;
int y_offset;
int x_offset;

View file

@ -1006,7 +1006,7 @@ MenuReturn menu ( char **lines, char **input, char *prompt, Time *time, int *shi
max_rows = config.menu_lines;
}
// More hacks.
if ( config.wmode == HORIZONTAL )
if ( config.hmode == HORIZONTAL )
{
max_rows = 1;
}
@ -1020,7 +1020,7 @@ MenuReturn menu ( char **lines, char **input, char *prompt, Time *time, int *shi
int element_width = w - ( 2 * ( config.padding ) );
// Divide by the # columns
element_width /= config.menu_columns;
if ( config.wmode == HORIZONTAL )
if ( config.hmode == HORIZONTAL )
{
element_width = ( w - ( 2 * ( config.padding ) ) - max_elements * LINE_MARGIN ) / ( max_elements + 1 );
}
@ -1081,12 +1081,12 @@ MenuReturn menu ( char **lines, char **input, char *prompt, Time *time, int *shi
for ( i = 0; i < max_elements; i++ )
{
int line = ( i ) % max_rows + ( ( config.wmode == VERTICAL ) ? 1 : 0 );
int col = ( i ) / max_rows + ( ( config.wmode == VERTICAL ) ? 0 : 1 );
int line = ( i ) % max_rows + ( ( config.hmode == VERTICAL ) ? 1 : 0 );
int col = ( i ) / max_rows + ( ( config.hmode == VERTICAL ) ? 0 : 1 );
boxes[i] = textbox_create ( box,
0,
( config.padding ) + col * ( element_width + LINE_MARGIN ), // X
line * line_height + config.padding + ( ( config.wmode == HORIZONTAL ) ? 0 : LINE_MARGIN ), // y
line * line_height + config.padding + ( ( config.hmode == HORIZONTAL ) ? 0 : LINE_MARGIN ), // y
element_width, // w
line_height, // h
config.menu_font, config.menu_fg, config.menu_bg, "", NULL );
@ -1094,7 +1094,7 @@ MenuReturn menu ( char **lines, char **input, char *prompt, Time *time, int *shi
}
// Arrows
textbox *arrowbox_top = NULL, *arrowbox_bottom = NULL;
if ( config.wmode == VERTICAL )
if ( config.hmode == VERTICAL )
{
arrowbox_top = textbox_create ( box, TB_AUTOHEIGHT | TB_AUTOWIDTH,
( config.padding ),
@ -1159,7 +1159,7 @@ MenuReturn menu ( char **lines, char **input, char *prompt, Time *time, int *shi
int h = line_height * ( max_rows + 1 ) + ( config.padding ) * 2 + LINE_MARGIN;
if ( config.wmode == HORIZONTAL )
if ( config.hmode == HORIZONTAL )
{
h = line_height + ( config.padding ) * 2;
}
@ -1232,7 +1232,7 @@ MenuReturn menu ( char **lines, char **input, char *prompt, Time *time, int *shi
max_elements, arrowbox_top,
arrowbox_bottom );
// Why do we need the specian -1?
if ( config.wmode == VERTICAL && max_elements > 0 )
if ( config.hmode == VERTICAL && max_elements > 0 )
{
XDrawLine ( display, main_window, gc, ( config.padding ),
line_height + ( config.padding ) + ( LINE_MARGIN - 2 ) / 2,
@ -1901,7 +1901,7 @@ static void parse_cmd_options ( int argc, char ** argv )
if ( find_arg ( argc, argv, "-hmode" ) >= 0 )
{
config.wmode = HORIZONTAL;
config.hmode = HORIZONTAL;
}
}

View file

@ -74,6 +74,7 @@ static XrmOption xrmOptions[] = {
{ xrm_Number, "xoffset", { .num = &config.x_offset }, NULL },
{ xrm_Number, "fixed_num_lines", { .num = &config.fixed_num_lines }, NULL },
{ xrm_Number, "columns", { .num = &config.menu_columns }, NULL },
{ xrm_Number, "hmode", { .num = &config.hmode }, NULL },
};