From ae47b2e0635250d74d1f61719bec9afeebec5b7f Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Mon, 19 Aug 2019 21:59:27 +0200 Subject: [Theme] @media limit to px. --- include/theme.h | 2 +- lexer/theme-lexer.l | 4 ++-- lexer/theme-parser.y | 25 ++++++++++++------------- source/theme.c | 8 ++++---- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/include/theme.h b/include/theme.h index 1dbbb403..9bcf6d8d 100644 --- a/include/theme.h +++ b/include/theme.h @@ -43,7 +43,7 @@ typedef enum { typedef struct ThemeMedia { ThemeMediaType type; - RofiDistance value; + int value; } ThemeMedia; /** diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l index a4db7c3f..cf287371 100644 --- a/lexer/theme-lexer.l +++ b/lexer/theme-lexer.l @@ -449,8 +449,8 @@ if ( queue == NULL ){ return T_LINK; } -{EM} { return T_UNIT_EM; } -{CH} { return T_UNIT_CH; } +{EM} { return T_UNIT_EM; } +{CH} { return T_UNIT_CH; } {PX} { return T_UNIT_PX; } {PERCENT} { return T_PERCENT; } {LS_SOLID} { return T_SOLID; } diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y index 23c3e627..0c95442f 100644 --- a/lexer/theme-parser.y +++ b/lexer/theme-parser.y @@ -233,7 +233,6 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b) %token T_MEDIA_SEP "-" %type t_entry -%type t_entry_my %type t_entry_list %type t_media_entry_list %type t_entry_name_path @@ -355,47 +354,47 @@ t_name_prefix_optional t_entry_name_path_selectors T_BOPEN t_property_list_optio g_hash_table_destroy ( $3 ); } } -| T_MEDIA T_PARENT_LEFT T_MEDIA_MIN T_MEDIA_SEP T_MEDIA_WIDTH T_PSEP t_property_distance T_PARENT_RIGHT T_BOPEN t_media_entry_list T_BCLOSE { +| T_MEDIA T_PARENT_LEFT T_MEDIA_MIN T_MEDIA_SEP T_MEDIA_WIDTH T_PSEP T_INT T_UNIT_PX T_PARENT_RIGHT T_BOPEN t_media_entry_list T_BCLOSE { ThemeWidget *widget = rofi_theme_find_or_create_name ( rofi_theme, "min-width" ); widget->set = TRUE; widget->media = g_malloc0(sizeof(ThemeMedia)); widget->media->type = THEME_MEDIA_TYPE_MIN_WIDTH; widget->media->value = $7; - for ( unsigned int i = 0; i < $10->num_widgets;i++) { - ThemeWidget *d = $10->widgets[i]; + for ( unsigned int i = 0; i < $11->num_widgets;i++) { + ThemeWidget *d = $11->widgets[i]; rofi_theme_parse_merge_widgets(widget, d); } } -| T_MEDIA T_PARENT_LEFT T_MEDIA_MIN T_MEDIA_SEP T_MEDIA_HEIGHT T_PSEP t_property_distance T_PARENT_RIGHT T_BOPEN t_media_entry_list T_BCLOSE { +| T_MEDIA T_PARENT_LEFT T_MEDIA_MIN T_MEDIA_SEP T_MEDIA_HEIGHT T_PSEP T_INT T_UNIT_PX T_PARENT_RIGHT T_BOPEN t_media_entry_list T_BCLOSE { ThemeWidget *widget = rofi_theme_find_or_create_name ( rofi_theme, "min-height" ); widget->set = TRUE; widget->media = g_malloc0(sizeof(ThemeMedia)); widget->media->type = THEME_MEDIA_TYPE_MIN_HEIGHT; widget->media->value = $7; - for ( unsigned int i = 0; i < $10->num_widgets;i++) { - ThemeWidget *d = $10->widgets[i]; + for ( unsigned int i = 0; i < $11->num_widgets;i++) { + ThemeWidget *d = $11->widgets[i]; rofi_theme_parse_merge_widgets(widget, d); } } -| T_MEDIA T_PARENT_LEFT T_MEDIA_MAX T_MEDIA_SEP T_MEDIA_WIDTH T_PSEP t_property_distance T_PARENT_RIGHT T_BOPEN t_media_entry_list T_BCLOSE { +| T_MEDIA T_PARENT_LEFT T_MEDIA_MAX T_MEDIA_SEP T_MEDIA_WIDTH T_PSEP T_INT T_UNIT_PX T_PARENT_RIGHT T_BOPEN t_media_entry_list T_BCLOSE { ThemeWidget *widget = rofi_theme_find_or_create_name ( rofi_theme, "max-width" ); widget->set = TRUE; widget->media = g_malloc0(sizeof(ThemeMedia)); widget->media->type = THEME_MEDIA_TYPE_MAX_WIDTH; widget->media->value = $7; - for ( unsigned int i = 0; i < $10->num_widgets;i++) { - ThemeWidget *d = $10->widgets[i]; + for ( unsigned int i = 0; i < $11->num_widgets;i++) { + ThemeWidget *d = $11->widgets[i]; rofi_theme_parse_merge_widgets(widget, d); } } -| T_MEDIA T_PARENT_LEFT T_MEDIA_MAX T_MEDIA_SEP T_MEDIA_HEIGHT T_PSEP t_property_distance T_PARENT_RIGHT T_BOPEN t_media_entry_list T_BCLOSE { +| T_MEDIA T_PARENT_LEFT T_MEDIA_MAX T_MEDIA_SEP T_MEDIA_HEIGHT T_PSEP T_INT T_UNIT_PX T_PARENT_RIGHT T_BOPEN t_media_entry_list T_BCLOSE { ThemeWidget *widget = rofi_theme_find_or_create_name ( rofi_theme, "max-height"); widget->set = TRUE; widget->media = g_malloc0(sizeof(ThemeMedia)); widget->media->type = THEME_MEDIA_TYPE_MAX_HEIGHT; widget->media->value = $7; - for ( unsigned int i = 0; i < $10->num_widgets;i++) { - ThemeWidget *d = $10->widgets[i]; + for ( unsigned int i = 0; i < $11->num_widgets;i++) { + ThemeWidget *d = $11->widgets[i]; rofi_theme_parse_merge_widgets(widget, d); } } diff --git a/source/theme.c b/source/theme.c index b0a84e68..3206bbfd 100644 --- a/source/theme.c +++ b/source/theme.c @@ -1049,7 +1049,7 @@ void rofi_theme_parse_process_conditionals ( void ) { case THEME_MEDIA_TYPE_MIN_WIDTH: { - int w = distance_get_pixel ( widget->media->value,ROFI_ORIENTATION_HORIZONTAL); + int w = widget->media->value; if ( mon.w >= w ){ printf("merge accepted\n"); for ( unsigned int x =0; x < widget->num_widgets; x++) { @@ -1060,7 +1060,7 @@ void rofi_theme_parse_process_conditionals ( void ) } case THEME_MEDIA_TYPE_MAX_WIDTH: { - int w = distance_get_pixel ( widget->media->value,ROFI_ORIENTATION_HORIZONTAL); + int w = widget->media->value; if ( mon.w < w ){ printf("merge accepted\n"); for ( unsigned int x =0; x < widget->num_widgets; x++) { @@ -1071,7 +1071,7 @@ void rofi_theme_parse_process_conditionals ( void ) } case THEME_MEDIA_TYPE_MIN_HEIGHT: { - int h = distance_get_pixel ( widget->media->value,ROFI_ORIENTATION_VERTICAL ); + int h = widget->media->value; if ( mon.h >= h ){ printf("merge accepted\n"); for ( unsigned int x =0; x < widget->num_widgets; x++) { @@ -1082,7 +1082,7 @@ void rofi_theme_parse_process_conditionals ( void ) } case THEME_MEDIA_TYPE_MAX_HEIGHT: { - int h = distance_get_pixel ( widget->media->value,ROFI_ORIENTATION_VERTICAL); + int h = widget->media->value; if ( mon.h < h ){ printf("merge accepted\n"); for ( unsigned int x =0; x < widget->num_widgets; x++) { -- cgit v1.2.3