diff --git a/include/helper.h b/include/helper.h index 83a06970..bcae4810 100644 --- a/include/helper.h +++ b/include/helper.h @@ -399,6 +399,33 @@ char *helper_string_replace_if_exists(char *string, ...); */ char *helper_get_theme_path(const char *file, const char *ext); +/** + * @param name The name of the element to find. + * @param state The state of the element. + * @param exact If the match should be exact, or parent can be included. + * + * Find the configuration element. If not exact, the closest specified element + * is returned. + * + * @returns the ThemeWidget if found, otherwise NULL. + */ +ConfigEntry *rofi_config_find_widget(const char *name, const char *state, + gboolean exact); + +/** + * @param widget The widget to find the property on. + * @param type The %PropertyType to find. + * @param property The property to find. + * @param exact If the property should only be found on this widget, or on + * parents if not found. + * + * Find the property on the widget. If not exact, the parents are searched + * recursively until match is found. + * + * @returns the Property if found, otherwise NULL. + */ +Property *rofi_theme_find_property(ConfigEntry *widget, PropertyType type, + const char *property, gboolean exact); G_END_DECLS /**@} */ diff --git a/include/rofi-types.h b/include/rofi-types.h index 807a2556..4fc878d4 100644 --- a/include/rofi-types.h +++ b/include/rofi-types.h @@ -297,6 +297,57 @@ typedef struct Property { PropertyValue value; } Property; +/** + * Describe the media constraint type. + */ +typedef enum { + /** Minimum width constraint. */ + THEME_MEDIA_TYPE_MIN_WIDTH, + /** Maximum width constraint. */ + THEME_MEDIA_TYPE_MAX_WIDTH, + /** Minimum height constraint. */ + THEME_MEDIA_TYPE_MIN_HEIGHT, + /** Maximum height constraint. */ + THEME_MEDIA_TYPE_MAX_HEIGHT, + /** Monitor id constraint. */ + THEME_MEDIA_TYPE_MON_ID, + /** Minimum aspect ratio constraint. */ + THEME_MEDIA_TYPE_MIN_ASPECT_RATIO, + /** Maximum aspect ratio constraint. */ + THEME_MEDIA_TYPE_MAX_ASPECT_RATIO, + /** Boolean option for use with env. */ + THEME_MEDIA_TYPE_BOOLEAN, + /** Invalid entry. */ + THEME_MEDIA_TYPE_INVALID, +} ThemeMediaType; + +/** + * Theme Media description. + */ +typedef struct ThemeMedia { + ThemeMediaType type; + double value; + gboolean boolv; +} ThemeMedia; + +/** + * ThemeWidget. + */ +typedef struct ThemeWidget { + int set; + char *name; + + unsigned int num_widgets; + struct ThemeWidget **widgets; + + ThemeMedia *media; + + GHashTable *properties; + + struct ThemeWidget *parent; +} ThemeWidget; + +typedef ThemeWidget ConfigEntry; /** * Structure to hold a range. */ diff --git a/include/theme.h b/include/theme.h index 2dd31d5c..aaba03c8 100644 --- a/include/theme.h +++ b/include/theme.h @@ -32,56 +32,6 @@ #include #include -/** - * Describe the media constraint type. - */ -typedef enum { - /** Minimum width constraint. */ - THEME_MEDIA_TYPE_MIN_WIDTH, - /** Maximum width constraint. */ - THEME_MEDIA_TYPE_MAX_WIDTH, - /** Minimum height constraint. */ - THEME_MEDIA_TYPE_MIN_HEIGHT, - /** Maximum height constraint. */ - THEME_MEDIA_TYPE_MAX_HEIGHT, - /** Monitor id constraint. */ - THEME_MEDIA_TYPE_MON_ID, - /** Minimum aspect ratio constraint. */ - THEME_MEDIA_TYPE_MIN_ASPECT_RATIO, - /** Maximum aspect ratio constraint. */ - THEME_MEDIA_TYPE_MAX_ASPECT_RATIO, - /** Boolean option for use with env. */ - THEME_MEDIA_TYPE_BOOLEAN, - /** Invalid entry. */ - THEME_MEDIA_TYPE_INVALID, -} ThemeMediaType; - -/** - * Theme Media description. - */ -typedef struct ThemeMedia { - ThemeMediaType type; - double value; - gboolean boolv; -} ThemeMedia; - -/** - * ThemeWidget. - */ -typedef struct ThemeWidget { - int set; - char *name; - - unsigned int num_widgets; - struct ThemeWidget **widgets; - - ThemeMedia *media; - - GHashTable *properties; - - struct ThemeWidget *parent; -} ThemeWidget; - /** * Global pointer to the current active theme. */ @@ -370,34 +320,6 @@ void distance_get_linestyle(RofiDistance d, cairo_t *draw); ThemeWidget *rofi_theme_find_widget(const char *name, const char *state, gboolean exact); -/** - * @param name The name of the element to find. - * @param state The state of the element. - * @param exact If the match should be exact, or parent can be included. - * - * Find the configuration element. If not exact, the closest specified element - * is returned. - * - * @returns the ThemeWidget if found, otherwise NULL. - */ -ThemeWidget *rofi_config_find_widget(const char *name, const char *state, - gboolean exact); - -/** - * @param widget The widget to find the property on. - * @param type The %PropertyType to find. - * @param property The property to find. - * @param exact If the property should only be found on this widget, or on - * parents if not found. - * - * Find the property on the widget. If not exact, the parents are searched - * recursively until match is found. - * - * @returns the Property if found, otherwise NULL. - */ -Property *rofi_theme_find_property(ThemeWidget *widget, PropertyType type, - const char *property, gboolean exact); - /** * Reset the current theme. */ diff --git a/source/mode.c b/source/mode.c index 02c4aaee..990bea56 100644 --- a/source/mode.c +++ b/source/mode.c @@ -34,6 +34,7 @@ #include "rofi-icon-fetcher.h" // This one should only be in mode implementations. +#include "helper.h" #include "mode-private.h" /** * @ingroup MODE diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c index 5e45a0d5..51273adf 100644 --- a/source/widgets/textbox.c +++ b/source/widgets/textbox.c @@ -561,8 +561,8 @@ static void textbox_draw(widget *wid, cairo_t *draw) { tb->cursor_x_pos = x + cursor_x; } if (tb->blink) { - // save the state so we can restore the text color afterwards - cairo_save(draw); + // use text color as fallback for themes that don't specify the cursor + // color rofi_theme_get_color(WIDGET(tb), "cursor-color", draw); cairo_rectangle(draw, x + cursor_x, y + cursor_y, cursor_pixel_width, cursor_height); @@ -576,7 +576,6 @@ static void textbox_draw(widget *wid, cairo_t *draw) { } else { cairo_fill(draw); } - cairo_restore(draw); } } }