1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2025-01-27 15:25:24 -05:00

Add active/urgent color.

This commit is contained in:
QC 2015-04-03 18:40:07 +02:00
parent 957ffe5fcf
commit f2c4aff37c
5 changed files with 27 additions and 20 deletions

View file

@ -47,7 +47,9 @@ Settings config = {
/** Font */ /** Font */
.menu_font = "mono 12", .menu_font = "mono 12",
/** Foreground color */ /** Foreground color */
.menu_fg = "#222222", .menu_fg = "#222222",
.menu_fg_urgent = "#aa0000",
.menu_fg_active = "#00aaff",
/** Background color */ /** Background color */
.menu_bg = "#f2f1f0", .menu_bg = "#f2f1f0",
/** Background color alternate row */ /** Background color alternate row */

View file

@ -154,6 +154,8 @@ typedef struct _Settings
char * menu_font; char * menu_font;
/** Foreground color */ /** Foreground color */
char * menu_fg; char * menu_fg;
char * menu_fg_urgent;
char * menu_fg_active;
/** Background color */ /** Background color */
char * menu_bg; char * menu_bg;
/** Background color alt */ /** Background color alt */

View file

@ -43,10 +43,10 @@ typedef enum
STATE_MASK = ( NORMAL | ALT | HIGHLIGHT ), STATE_MASK = ( NORMAL | ALT | HIGHLIGHT ),
BOLD = 8, ACTIVE = 8,
ITALIC = 16, URGENT = 16,
FMOD_MASK = ( BOLD | ITALIC ) FMOD_MASK = ( ACTIVE | URGENT )
} TextBoxFontType; } TextBoxFontType;
textbox* textbox_create ( Window parent, textbox* textbox_create ( Window parent,

View file

@ -523,10 +523,10 @@ static const char *mgrv ( unsigned int selected_line, void *sw, G_GNUC_UNUSED in
{ {
SwitcherModePrivateData *rmpd = ( (Switcher *) sw )->private_data; SwitcherModePrivateData *rmpd = ( (Switcher *) sw )->private_data;
if ( window_client ( display, rmpd->ids->array[selected_line] )->demands ) { if ( window_client ( display, rmpd->ids->array[selected_line] )->demands ) {
*state |= ITALIC; *state |= URGENT;
} }
if ( window_client ( display, rmpd->ids->array[selected_line] )->active ) { if ( window_client ( display, rmpd->ids->array[selected_line] )->active ) {
*state |= BOLD; *state |= ACTIVE;
} }
return rmpd->cmd_list[selected_line]; return rmpd->cmd_list[selected_line];
} }

View file

@ -47,6 +47,8 @@ extern Display *display;
* Font + font color cache. * Font + font color cache.
* Avoid re-loading font on every change on every textbox. * Avoid re-loading font on every change on every textbox.
*/ */
XftColor color_fg_urgent;
XftColor color_fg_active;
XftColor color_fg; XftColor color_fg;
XftColor color_bg; XftColor color_bg;
XftColor color_hlfg; XftColor color_hlfg;
@ -99,9 +101,9 @@ textbox* textbox_create ( Window parent,
tb->window = XCreateWindow ( display, tb->parent, tb->x, tb->y, tb->w, tb->h, 0, vinfo->depth, tb->window = XCreateWindow ( display, tb->parent, tb->x, tb->y, tb->w, tb->h, 0, vinfo->depth,
InputOutput, vinfo->visual, CWColormap | CWBorderPixel | CWBackPixel, &attr ); InputOutput, vinfo->visual, CWColormap | CWBorderPixel | CWBackPixel, &attr );
// need to preload the font to calc line height PangoFontDescription *pfd = pango_font_description_from_string ( config.menu_font );
// Force update of font descriptor. pango_layout_set_font_description ( tb->layout, pfd );
tb->tbft = ~tbft; pango_font_description_free ( pfd );
textbox_font ( tb, tbft ); textbox_font ( tb, tbft );
textbox_text ( tb, text ? text : "" ); textbox_text ( tb, text ? text : "" );
@ -127,17 +129,6 @@ textbox* textbox_create ( Window parent,
// set an Xft font by name // set an Xft font by name
void textbox_font ( textbox *tb, TextBoxFontType tbft ) void textbox_font ( textbox *tb, TextBoxFontType tbft )
{ {
if ( ( tbft & FMOD_MASK ) != ( tb->tbft & FMOD_MASK ) ) {
PangoFontDescription *pfd = pango_font_description_from_string ( config.menu_font );
if ( ( tbft & BOLD ) == BOLD ) {
pango_font_description_set_weight ( pfd, PANGO_WEIGHT_BOLD );
}
if ( ( tbft & ITALIC ) == ITALIC ) {
pango_font_description_set_style ( pfd, PANGO_STYLE_ITALIC );
}
pango_layout_set_font_description ( tb->layout, pfd );
pango_font_description_free ( pfd );
}
switch ( ( tbft & STATE_MASK ) ) switch ( ( tbft & STATE_MASK ) )
{ {
case HIGHLIGHT: case HIGHLIGHT:
@ -154,6 +145,14 @@ void textbox_font ( textbox *tb, TextBoxFontType tbft )
tb->color_fg = color_fg; tb->color_fg = color_fg;
break; break;
} }
if ( ( tbft & FMOD_MASK ) ) {
if ( ( tbft & ACTIVE ) ) {
tb->color_fg = color_fg_active;
}
else if ( ( tbft & URGENT ) ) {
tb->color_fg = color_fg_urgent;
}
}
tb->tbft = tbft; tb->tbft = tbft;
} }
@ -628,6 +627,8 @@ void textbox_setup ( XVisualInfo *visual, Colormap colormap,
parse_color ( visual_info->visual, target_colormap, bg, &color_bg ); parse_color ( visual_info->visual, target_colormap, bg, &color_bg );
parse_color ( visual_info->visual, target_colormap, fg, &color_fg ); parse_color ( visual_info->visual, target_colormap, fg, &color_fg );
parse_color ( visual_info->visual, target_colormap, config.menu_fg_active, &color_fg_active );
parse_color ( visual_info->visual, target_colormap, config.menu_fg_urgent, &color_fg_urgent );
parse_color ( visual_info->visual, target_colormap, bg_alt, &color_bg_alt ); parse_color ( visual_info->visual, target_colormap, bg_alt, &color_bg_alt );
parse_color ( visual_info->visual, target_colormap, hlfg, &color_hlfg ); parse_color ( visual_info->visual, target_colormap, hlfg, &color_hlfg );
parse_color ( visual_info->visual, target_colormap, hlbg, &color_hlbg ); parse_color ( visual_info->visual, target_colormap, hlbg, &color_hlbg );
@ -641,6 +642,8 @@ void textbox_cleanup ( void )
{ {
if ( p_context ) { if ( p_context ) {
XftColorFree ( display, visual_info->visual, target_colormap, &color_fg ); XftColorFree ( display, visual_info->visual, target_colormap, &color_fg );
XftColorFree ( display, visual_info->visual, target_colormap, &color_fg_urgent );
XftColorFree ( display, visual_info->visual, target_colormap, &color_fg_active );
XftColorFree ( display, visual_info->visual, target_colormap, &color_bg ); XftColorFree ( display, visual_info->visual, target_colormap, &color_bg );
XftColorFree ( display, visual_info->visual, target_colormap, &color_bg_alt ); XftColorFree ( display, visual_info->visual, target_colormap, &color_bg_alt );
XftColorFree ( display, visual_info->visual, target_colormap, &color_hlfg ); XftColorFree ( display, visual_info->visual, target_colormap, &color_hlfg );