From b5f1e97e0f7468df48c5e3a2be6b34b7ff8b3efc Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sun, 24 Sep 2023 20:06:08 +0200 Subject: [PATCH 01/28] [XCB] Try to be smarter with where mouse click started. fixes: #1896 --- include/xcb-internal.h | 2 +- source/xcb.c | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/include/xcb-internal.h b/include/xcb-internal.h index 8b012a794..1e44cd5bc 100644 --- a/include/xcb-internal.h +++ b/include/xcb-internal.h @@ -64,7 +64,7 @@ struct _xcb_stuff { } xkb; xcb_timestamp_t last_timestamp; NkBindingsSeat *bindings_seat; - gboolean mouse_seen; + uint32_t mouse_seen; xcb_window_t focus_revert; char *clipboard; }; diff --git a/source/xcb.c b/source/xcb.c index 62dddfbf0..375cfcfcf 100644 --- a/source/xcb.c +++ b/source/xcb.c @@ -1264,9 +1264,6 @@ static void main_loop_x11_event_handler_view(xcb_generic_event_t *event) { case XCB_MOTION_NOTIFY: { xcb_motion_notify_event_t *xme = (xcb_motion_notify_event_t *)event; gboolean button_mask = xme->state & XCB_EVENT_MASK_BUTTON_1_MOTION; - if (button_mask && config.click_to_exit == TRUE) { - xcb->mouse_seen = TRUE; - } rofi_view_handle_mouse_motion(state, xme->event_x, xme->event_y, !button_mask && config.hover_select); break; @@ -1285,6 +1282,7 @@ static void main_loop_x11_event_handler_view(xcb_generic_event_t *event) { } else if (x11_button_to_nk_bindings_scroll(bpe->detail, &axis, &steps)) { nk_bindings_seat_handle_scroll(xcb->bindings_seat, NULL, axis, steps); } + xcb->mouse_seen++; break; } case XCB_SELECTION_CLEAR: { @@ -1347,7 +1345,7 @@ static void main_loop_x11_event_handler_view(xcb_generic_event_t *event) { if (!xcb->mouse_seen) { rofi_view_temp_click_to_exit(state, bre->event); } - xcb->mouse_seen = FALSE; + xcb->mouse_seen--; } break; } From 1243dca65b80891851f60661c65570fbd528e6c6 Mon Sep 17 00:00:00 2001 From: Quentin Glidic Date: Mon, 25 Sep 2023 18:04:32 +0200 Subject: [PATCH 02/28] gitmodules: Update libnkutils Signed-off-by: Quentin Glidic --- meson.build | 1 - source/keyb.c | 8 ++++++-- subprojects/libnkutils | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index 8a9162bd7..ff5fb2b35 100644 --- a/meson.build +++ b/meson.build @@ -129,7 +129,6 @@ config_h = configure_file(output: 'config.h', configuration: header_conf) nk_options = [ 'bindings=true', - 'xdg-theme=true', 'git-work-tree=@0@'.format(meson.source_root()), ] nk = subproject('libnkutils', default_options: nk_options) diff --git a/source/keyb.c b/source/keyb.c index c30b1d8c5..9de5829b9 100644 --- a/source/keyb.c +++ b/source/keyb.c @@ -448,7 +448,9 @@ gboolean parse_keys_abe(NkBindings *bindings) { entry = strtok_r(NULL, sep, &sp)) { if (!nk_bindings_add_binding(bindings, b->scope, entry, binding_check_action, binding_trigger_action, - GUINT_TO_POINTER(b->id), NULL, &error)) { + GUINT_TO_POINTER(b->id), NULL, + NK_BINDINGS_ADD_FLAG_NONE, + &error)) { if (error->code == NK_BINDINGS_ERROR_ALREADY_REGISTERED && error->domain == NK_BINDINGS_ERROR) { char *str = g_markup_printf_escaped( @@ -485,7 +487,9 @@ gboolean parse_keys_abe(NkBindings *bindings) { for (gsize j = 1; j < G_N_ELEMENTS(mouse_default_bindings); ++j) { nk_bindings_add_binding(bindings, i, mouse_default_bindings[j], binding_check_action, binding_trigger_action, - GSIZE_TO_POINTER(j), NULL, NULL); + GSIZE_TO_POINTER(j), NULL, + NK_BINDINGS_ADD_FLAG_NONE, + NULL); } } diff --git a/subprojects/libnkutils b/subprojects/libnkutils index 09ca429c0..72bd7fb07 160000 --- a/subprojects/libnkutils +++ b/subprojects/libnkutils @@ -1 +1 @@ -Subproject commit 09ca429c08530ddb50ba1029f98ca14da7b0b7fa +Subproject commit 72bd7fb07f627a864e724639eea9fab6cccbd77c From 05327773d905adae7871adffdae15554a5616a3c Mon Sep 17 00:00:00 2001 From: vE5li Date: Wed, 27 Sep 2023 18:23:18 +0200 Subject: [PATCH 03/28] Fix text color when `cursor-color` is set (#1901) * Fix text color when cursor color is set * Add comment --- source/widgets/textbox.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c index c1f0eabcd..592504039 100644 --- a/source/widgets/textbox.c +++ b/source/widgets/textbox.c @@ -540,6 +540,9 @@ static void textbox_draw(widget *wid, cairo_t *draw) { tb->cursor_x_pos = x + cursor_x; } if (tb->blink) { + // This save/restore state is necessary to render the text in the + // correct color when `cursor-color` is set + 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); @@ -555,6 +558,7 @@ static void textbox_draw(widget *wid, cairo_t *draw) { } else { cairo_fill(draw); } + cairo_restore(draw); } } From a6d297591ef4d389a3d0043afb887b0bdb48a317 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sat, 30 Sep 2023 15:58:31 +0200 Subject: [PATCH 04/28] [XCB] Make sure that window maker is 0 terminated before usage. Thanks to Omar Polo and bsdmp --- source/xcb.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/source/xcb.c b/source/xcb.c index 375cfcfcf..4e1039790 100644 --- a/source/xcb.c +++ b/source/xcb.c @@ -1617,7 +1617,7 @@ char *x11_helper_get_window_manager(void) { xcb_ewmh_get_wm_name_unchecked(&(xcb->ewmh), wm_win); if (xcb_ewmh_get_wm_name_reply(&(xcb->ewmh), cookie, &wtitle, (void *)0)) { if (wtitle.strings_len > 0) { - retv = g_strdup(wtitle.strings); + retv = g_strndup(wtitle.strings, wtitle.strings_len); } xcb_ewmh_get_utf8_strings_reply_wipe(&wtitle); } @@ -1636,13 +1636,16 @@ static void x11_helper_discover_window_manager(void) { xcb_ewmh_get_wm_name_unchecked(&(xcb->ewmh), wm_win); if (xcb_ewmh_get_wm_name_reply(&(xcb->ewmh), cookie, &wtitle, (void *)0)) { if (wtitle.strings_len > 0) { - g_debug("Found window manager: |%s|", wtitle.strings); - if (g_strcmp0(wtitle.strings, "i3") == 0) { + // Copy the string and add terminating '\0'. + char *str = g_strndup(wtitle.strings, wtitle.strings_len); + g_debug("Found window manager: |%s|", str); + if (g_strcmp0(str, "i3") == 0) { current_window_manager = WM_DO_NOT_CHANGE_CURRENT_DESKTOP | WM_PANGO_WORKSPACE_NAMES; - } else if (g_strcmp0(wtitle.strings, "bspwm") == 0) { + } else if (g_strcmp0(str, "bspwm") == 0) { current_window_manager = WM_ROOT_WINDOW_OFFSET; } + g_free(str); } xcb_ewmh_get_utf8_strings_reply_wipe(&wtitle); } From c78179dcc8fe7d19ae713d4fa009bec76fd691f8 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Tue, 3 Oct 2023 21:06:53 +0200 Subject: [PATCH 05/28] [lexer] Add dmenu as enabled option for media type. fixes: #1903 --- doc/rofi-theme.5 | 16 ++++++++++++++-- doc/rofi-theme.5.markdown | 11 +++++++++-- lexer/theme-lexer.l | 4 ++++ source/rofi.c | 10 +++++----- test/box-test.c | 1 + test/scrollbar-test.c | 1 + test/textbox-test.c | 1 + test/theme-parser-test.c | 2 ++ test/widget-test.c | 1 + 9 files changed, 38 insertions(+), 9 deletions(-) diff --git a/doc/rofi-theme.5 b/doc/rofi-theme.5 index eb4c3fa0f..7a4708fae 100644 --- a/doc/rofi-theme.5 +++ b/doc/rofi-theme.5 @@ -2206,7 +2206,8 @@ It supports the following keys as constraint: .IP \(bu 2 \fB\fCmonitor-id\fR: The monitor id, see rofi -help for id's. .IP \(bu 2 -\fB\fCenabled\fR: Boolean option to enable. Supports environment variable. +\fB\fCenabled\fR: Boolean option to enable. Supports environment variable +or DMENU to detect if in dmenu mode. .RE @@ -2229,7 +2230,18 @@ added. .RS .nf -@media ( enabled: env(DO_LIGHT, false ) { +@media ( enabled: env(DO_LIGHT, false )) { + +} + +.fi +.RE + +.PP +.RS + +.nf +@media ( enabled: DMENU) { } diff --git a/doc/rofi-theme.5.markdown b/doc/rofi-theme.5.markdown index ea60a4c50..f1778e659 100644 --- a/doc/rofi-theme.5.markdown +++ b/doc/rofi-theme.5.markdown @@ -1497,7 +1497,8 @@ It supports the following keys as constraint: - `min-aspect-ratio` load when aspect ratio is over value. - `max-aspect-ratio`: load when aspect ratio is under value. - `monitor-id`: The monitor id, see rofi -help for id's. -- `enabled`: Boolean option to enable. Supports environment variable. +- `enabled`: Boolean option to enable. Supports environment variable + or DMENU to detect if in dmenu mode. @media takes an integer number or a fraction, for integer number `px` can be added. @@ -1509,7 +1510,13 @@ added. ``` ```css -@media ( enabled: env(DO_LIGHT, false ) { +@media ( enabled: env(DO_LIGHT, false )) { + +} +``` + +```css +@media ( enabled: DMENU) { } ``` diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l index 8edd776e6..0a8441583 100644 --- a/lexer/theme-lexer.l +++ b/lexer/theme-lexer.l @@ -49,6 +49,7 @@ #define LOG_DOMAIN "Parser" int last_state = 0; +extern int rofi_is_in_dmenu_mode; const char *rasi_theme_file_extensions[] = {".rasi", ".rasinc", NULL}; /** @@ -298,6 +299,8 @@ CONFIGURATION (?i:configuration) MEDIA_TYPES (monitor-id|(min|max)-(width|height|aspect-ratio)|enabled) +DMENU (?i:dmenu) + %x INCLUDE %x PROPERTIES %x PROPERTIES_ENV @@ -513,6 +516,7 @@ if ( queue == NULL ) {
":" { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); BEGIN(PROPERTIES); return T_PSEP; } ";" { BEGIN(GPOINTER_TO_INT ( g_queue_pop_head ( queue ))); return T_PCLOSE;} (true|false) { yylval->bval= g_strcmp0(yytext, "true") == 0; return T_BOOLEAN;} +{DMENU} { yylval->bval = rofi_is_in_dmenu_mode; return T_BOOLEAN;} {NUMBER}\.{NUMBER} { yylval->fval = g_ascii_strtod(yytext, NULL); return T_DOUBLE;} {NUMBER} { yylval->ival = (int)g_ascii_strtoll(yytext, NULL, 10); return T_INT;} {UNARYMIN} { return T_MIN; } diff --git a/source/rofi.c b/source/rofi.c index 0b98c4612..3d6917f8e 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -139,7 +139,7 @@ NkBindings *bindings = NULL; GMainLoop *main_loop = NULL; /** Flag indicating we are in dmenu mode. */ -static int dmenu_mode = FALSE; +int rofi_is_in_dmenu_mode = FALSE; /** Rofi's return code */ int return_code = EXIT_SUCCESS; @@ -789,7 +789,7 @@ static gboolean startup(G_GNUC_UNUSED gpointer data) { } } // Dmenu mode. - if (dmenu_mode == TRUE) { + if (rofi_is_in_dmenu_mode == TRUE) { // force off sidebar mode: config.sidebar_mode = FALSE; int retv = dmenu_mode_dialog(); @@ -936,14 +936,14 @@ int main(int argc, char *argv[]) { // This has two possible causes. // 1 the user specifies it on the command-line. if (find_arg("-dmenu") >= 0) { - dmenu_mode = TRUE; + rofi_is_in_dmenu_mode = TRUE; } // 2 the binary that executed is called dmenu (e.g. symlink to rofi) else { // Get the base name of the executable called. char *base_name = g_path_get_basename(argv[0]); const char *const dmenu_str = "dmenu"; - dmenu_mode = (strcmp(base_name, dmenu_str) == 0); + rofi_is_in_dmenu_mode = (strcmp(base_name, dmenu_str) == 0); // Free the basename for dmenu detection. g_free(base_name); } @@ -1103,7 +1103,7 @@ int main(int argc, char *argv[]) { /** dirty hack for dmenu compatibility */ char *windowid = NULL; - if (!dmenu_mode) { + if (!rofi_is_in_dmenu_mode) { // setup_modes if (setup_modes()) { cleanup(); diff --git a/test/box-test.c b/test/box-test.c index 7faa654bd..54afcbcaf 100644 --- a/test/box-test.c +++ b/test/box-test.c @@ -41,6 +41,7 @@ #include #include unsigned int test = 0; +int rofi_is_in_dmenu_mode = 0; #define TASSERT(a) \ { \ assert(a); \ diff --git a/test/scrollbar-test.c b/test/scrollbar-test.c index fa4d0df3a..57da2ef94 100644 --- a/test/scrollbar-test.c +++ b/test/scrollbar-test.c @@ -59,6 +59,7 @@ unsigned int test = 0; } \ } +int rofi_is_in_dmenu_mode = 0; ThemeWidget *rofi_configuration = NULL; uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name, diff --git a/test/textbox-test.c b/test/textbox-test.c index 0ddfc50fb..3c7d67980 100644 --- a/test/textbox-test.c +++ b/test/textbox-test.c @@ -46,6 +46,7 @@ #include "rofi-icon-fetcher.h" static int test = 0; unsigned int normal_window_mode = 0; +int rofi_is_in_dmenu_mode = 0; #define TASSERT(a) \ { \ diff --git a/test/theme-parser-test.c b/test/theme-parser-test.c index 7eeb45089..81ae02301 100644 --- a/test/theme-parser-test.c +++ b/test/theme-parser-test.c @@ -47,6 +47,8 @@ #define REAL_COMPARE_DELTA 0.001 +int rofi_is_in_dmenu_mode = 0; + uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name, G_GNUC_UNUSED const int size) { return 0; diff --git a/test/widget-test.c b/test/widget-test.c index 69f321322..29783d673 100644 --- a/test/widget-test.c +++ b/test/widget-test.c @@ -40,6 +40,7 @@ #include #include unsigned int test = 0; +int rofi_is_in_dmenu_mode = 0; #define TASSERT(a) \ { \ assert(a); \ From 4feb278ad08f95448b2461f8bca77a5253bf3e81 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Fri, 6 Oct 2023 19:34:28 +0200 Subject: [PATCH 06/28] Change version as optional. --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index b148e95e7..39b3dd4dd 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -103,7 +103,7 @@ body: description: I confirm that I verified the issue still exists in the latest stable release. options: - label: "Yes, I have checked the problem exists in the latest stable version" - required: true + required: false From 9cea843b4df98884a440acb50df1a1d1d667a4c5 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sat, 7 Oct 2023 10:56:05 +0200 Subject: [PATCH 07/28] [ReleaseNotes] Start working on notes --- releasenotes/1.7.6/release-1.7.6.markdown | 47 +++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 releasenotes/1.7.6/release-1.7.6.markdown diff --git a/releasenotes/1.7.6/release-1.7.6.markdown b/releasenotes/1.7.6/release-1.7.6.markdown new file mode 100644 index 000000000..d4aa24f31 --- /dev/null +++ b/releasenotes/1.7.6/release-1.7.6.markdown @@ -0,0 +1,47 @@ +# 1.7.6: Traveling Time + +## Recursive file browser + +## Copy to clipboard support + +## entry box history + +## Fix calc + +> NOTE: Slight change in language, this might break theme. + +## Text outline + +## Website + +# Thanks to + +Big thanks to everybody reporting issues. +Special thanks goes to: + + * a1346054 + * aloispichler + * Amith Mohanan + * Christian Friedow + * cognitiond + * David Kosorin + * Dimitris Triantafyllidis + * duarm + * Fabian Winter + * Gutyina Gergő + * Jasper Lievisse Adriaanse + * Jorge + * Martin Weinelt + * Morgane Glidic + * Naïm Favier + * Nikita Zlobin + * nomoo + * notuxic + * Rasmus Steinke + * Tim Pope + * TonCherAmi + * vE5li + * Yuta Katayama + * Danny Colin + +Apologies if I mistyped or missed anybody. From cf8fb53be6d0fe47205fa78a2e710788d3f146fb Mon Sep 17 00:00:00 2001 From: Qball Cow Date: Fri, 20 Oct 2023 19:44:30 +0200 Subject: [PATCH 08/28] Update releasenotes. --- releasenotes/1.7.6/release-1.7.6.markdown | 51 ++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/releasenotes/1.7.6/release-1.7.6.markdown b/releasenotes/1.7.6/release-1.7.6.markdown index d4aa24f31..93e5c1fc5 100644 --- a/releasenotes/1.7.6/release-1.7.6.markdown +++ b/releasenotes/1.7.6/release-1.7.6.markdown @@ -2,18 +2,67 @@ ## Recursive file browser +An experimental file browser is introduced in this version. This recursively scans through the +users home directory (this is configurable) to find files. +Its designed to be asynchronous and very fast. + +The following settings can be configured: + +‘‘‘css +configuration { + recursivebrowser { + /** Directory the file browser starts in. */ + directory: "/some/directory"; + /** return 1 on cancel. */ + cancel‐returns‐1: true; + /** filter entries using regex */ + filter‐regex: "(.*cache.*|.*.o)"; + /** command */ + command: "xdg‐open"; + } +} +‘‘‘ + + ## Copy to clipboard support +Add support to copy current selected item to clipboard. +The added `control-c` binding copies the current selection to the clipboard. +THIS ONLY WORKS WITH CLIPBOARD MANAGER!!! Once rofi is closes, the data is +gone! + ## entry box history +You can now recall and move through previous queries by using +`kb-entry-history-up` or 'kb-entry-history-down` keys. (`Control-Up`, +`Control-Down`). + +The following settings can be configured: + +‘‘‘css +configuration { + entry { + max‐history: 30; + } +} +‘‘‘ + + ## Fix calc -> NOTE: Slight change in language, this might break theme. +There was a non-parsable grammar in the 'calc' part of the language. +The % operator (modulo) overloaded with percent and could leave to statements +having multiple valid but contradicting interpretations. To resolve this the modulo +operator is now `modulo`. Including in this patch several smaller issues with the +parser where fixed. ## Text outline ## Website +The current documentation is now also available on online at: +[https://davatorium.github.io/rofi/](https://davatorium.github.io/rofi/) + # Thanks to Big thanks to everybody reporting issues. From 1481030947b31f916757ec9874bcd0ce8fe24eb8 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Tue, 31 Oct 2023 11:28:45 +0100 Subject: [PATCH 09/28] [DRUN] Add {url} to drun-display-format. Escape exec. fixes: #1914 --- doc/rofi.1 | 2 ++ doc/rofi.1.markdown | 1 + source/modes/drun.c | 33 ++++++++++++++++++++++++++++++--- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/doc/rofi.1 b/doc/rofi.1 index e9330186d..022310aea 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -596,6 +596,8 @@ The format string for the \fB\fCdrun\fR dialog: \fBcategories\fP: the application's categories .IP \(bu 2 \fBcomment\fP: the application comment +.IP \(bu 2 +\fBurl\fP: The url in case of a link type desktop file .RE diff --git a/doc/rofi.1.markdown b/doc/rofi.1.markdown index eac04ea46..0f9c3cb60 100644 --- a/doc/rofi.1.markdown +++ b/doc/rofi.1.markdown @@ -381,6 +381,7 @@ The format string for the `drun` dialog: - **exec**: the application's executable - **categories**: the application's categories - **comment**: the application comment +- **url**: The url in case of a link type desktop file Pango markup can be used to formatting the output. diff --git a/source/modes/drun.c b/source/modes/drun.c index 69151f846..0bbb83335 100644 --- a/source/modes/drun.c +++ b/source/modes/drun.c @@ -124,6 +124,8 @@ typedef struct { char **keywords; /* Comments */ char *comment; + /* Url */ + char *url; /* Underlying key-file. */ GKeyFile *key_file; /* Used for sorting. */ @@ -155,6 +157,8 @@ typedef enum { DRUN_MATCH_FIELD_KEYWORDS, /** Comment */ DRUN_MATCH_FIELD_COMMENT, + /** Url */ + DRUN_MATCH_FIELD_URL, /** Number of DRunMatchingFields entries. */ DRUN_MATCH_NUM_FIELDS, } DRunMatchingFields; @@ -191,6 +195,11 @@ static DRunEntryField matching_entry_fields[DRUN_MATCH_NUM_FIELDS] = { .entry_field_name = "comment", .enabled_match = FALSE, .enabled_display = FALSE, + }, + { + .entry_field_name = "url", + .enabled_match = FALSE, + .enabled_display = FALSE, }}; struct _DRunModePrivateData { @@ -683,6 +692,13 @@ static void read_desktop_file(DRunModePrivateData *pd, const char *root, } else { pd->entry_list[pd->cmd_list_length].comment = NULL; } + if (matching_entry_fields[DRUN_MATCH_FIELD_URL].enabled_match || + matching_entry_fields[DRUN_MATCH_FIELD_URL].enabled_display) { + pd->entry_list[pd->cmd_list_length].url = + g_key_file_get_locale_string(kf, DRUN_GROUP_NAME, "URL", NULL, NULL); + } else { + pd->entry_list[pd->cmd_list_length].comment = NULL; + } pd->entry_list[pd->cmd_list_length].icon_name = g_key_file_get_locale_string(kf, DRUN_GROUP_NAME, "Icon", NULL, NULL); pd->entry_list[pd->cmd_list_length].icon = NULL; @@ -830,7 +846,7 @@ static gint drun_int_sort_list(gconstpointer a, gconstpointer b, *******************************************/ /** Version of the DRUN cache file format. */ -#define CACHE_VERSION 2 +#define CACHE_VERSION 3 static void drun_write_str(FILE *fd, const char *str) { size_t l = (str == NULL ? 0 : strlen(str)); fwrite(&l, sizeof(l), 1, fd); @@ -921,6 +937,7 @@ static void write_cache(DRunModePrivateData *pd, const char *cache_file) { drun_write_strv(fd, entry->keywords); drun_write_str(fd, entry->comment); + drun_write_str(fd, entry->url); drun_write_integer(fd, (int32_t)entry->type); } @@ -1325,6 +1342,8 @@ static char *_get_display_value(const Mode *sw, unsigned int selected_line, char *egn = NULL; char *en = NULL; char *ec = NULL; + char *ee = NULL; + char *eu = NULL; if (dr->generic_name) { egn = g_markup_escape_text(dr->generic_name, -1); } @@ -1334,14 +1353,22 @@ static char *_get_display_value(const Mode *sw, unsigned int selected_line, if (dr->comment) { ec = g_markup_escape_text(dr->comment, -1); } + if (dr->url) { + eu = g_markup_escape_text(dr->url, -1); + } + if (dr->exec) { + ee = g_markup_escape_text(dr->exec, -1); + } char *retv = helper_string_replace_if_exists( config.drun_display_format, "{generic}", egn, "{name}", en, "{comment}", - ec, "{exec}", dr->exec, "{categories}", cats, "{keywords}", keywords, - (char *)0); + ec, "{exec}", ee, "{categories}", cats, "{keywords}", keywords, "{url}", + eu, (char *)0); g_free(egn); g_free(en); g_free(ec); + g_free(eu); + g_free(ee); g_free(cats); g_free(keywords); return retv; From 3c87321258955737a5549b47a13181f747f2cf3a Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Tue, 31 Oct 2023 13:24:37 +0100 Subject: [PATCH 10/28] [DRun] Allow url field to be searched and fix c/p error Issue: #1914 --- source/modes/drun.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/modes/drun.c b/source/modes/drun.c index 0bbb83335..b05ce48e4 100644 --- a/source/modes/drun.c +++ b/source/modes/drun.c @@ -697,7 +697,7 @@ static void read_desktop_file(DRunModePrivateData *pd, const char *root, pd->entry_list[pd->cmd_list_length].url = g_key_file_get_locale_string(kf, DRUN_GROUP_NAME, "URL", NULL, NULL); } else { - pd->entry_list[pd->cmd_list_length].comment = NULL; + pd->entry_list[pd->cmd_list_length].url = NULL; } pd->entry_list[pd->cmd_list_length].icon_name = g_key_file_get_locale_string(kf, DRUN_GROUP_NAME, "Icon", NULL, NULL); @@ -1456,6 +1456,13 @@ static int drun_token_match(const Mode *data, rofi_int_matcher **tokens, } } } + if (matching_entry_fields[DRUN_MATCH_FIELD_URL].enabled_match) { + + // Match executable name. + if (test == tokens[j]->invert && rmpd->entry_list[index].url) { + test = helper_token_match(ftokens, rmpd->entry_list[index].url); + } + } if (matching_entry_fields[DRUN_MATCH_FIELD_COMMENT].enabled_match) { // Match executable name. From dbc1f8dcb4d22c2924d2b3a5f19b9be45c64a4eb Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Mon, 6 Nov 2023 20:02:48 +0100 Subject: [PATCH 11/28] [Dmenu][Script] Add 'display' row option to override whats displayed. --- Examples/test_script_mode.sh | 1 + doc/rofi-script.5 | 2 ++ doc/rofi-script.5.markdown | 2 ++ include/modes/dmenuscriptshared.h | 4 ++++ source/modes/dmenu.c | 22 +++++++++++++++++----- source/modes/script.c | 11 ++++++++++- source/rofi-icon-fetcher.c | 3 ++- 7 files changed, 38 insertions(+), 7 deletions(-) diff --git a/Examples/test_script_mode.sh b/Examples/test_script_mode.sh index d2773ae36..68b931be1 100755 --- a/Examples/test_script_mode.sh +++ b/Examples/test_script_mode.sh @@ -22,6 +22,7 @@ else echo -en "\0message\x1fSpecial boldmessage\n" echo -en "aap\0icon\x1ffolder\n" + echo -en "blob\0icon\x1ffolder\x1fdisplay\x1fblub\n" echo "noot" echo "mies" echo -en "-------------\0nonselectable\x1ftrue\n" diff --git a/doc/rofi-script.5 b/doc/rofi-script.5 index 3b17a2f1d..3882f8cb5 100644 --- a/doc/rofi-script.5 +++ b/doc/rofi-script.5 @@ -174,6 +174,8 @@ The following options are supported: .IP \(bu 2 \fBicon\fP: Set the icon for that row. .IP \(bu 2 +\fBdisplay\fP: Replace the displayed string. (Original string will still be used for searching) +.IP \(bu 2 \fBmeta\fP: Specify invisible search terms. .IP \(bu 2 \fBnonselectable\fP: If true the row cannot activated. diff --git a/doc/rofi-script.5.markdown b/doc/rofi-script.5.markdown index ed060e0d7..8d87afc20 100644 --- a/doc/rofi-script.5.markdown +++ b/doc/rofi-script.5.markdown @@ -133,6 +133,8 @@ The following options are supported: - **icon**: Set the icon for that row. +- **display**: Replace the displayed string. (Original string will still be used for searching) + - **meta**: Specify invisible search terms. - **nonselectable**: If true the row cannot activated. diff --git a/include/modes/dmenuscriptshared.h b/include/modes/dmenuscriptshared.h index e40e29541..bf83d7412 100644 --- a/include/modes/dmenuscriptshared.h +++ b/include/modes/dmenuscriptshared.h @@ -8,6 +8,10 @@ typedef struct { /** Entry content. (visible part) */ char *entry; + + /** Display */ + char *display; + /** Icon name to display. */ char *icon_name; /** Async icon fetch handler. */ diff --git a/source/modes/dmenu.c b/source/modes/dmenu.c index 41841074a..276153021 100644 --- a/source/modes/dmenu.c +++ b/source/modes/dmenu.c @@ -166,6 +166,7 @@ static void read_add(DmenuModePrivateData *pd, char *data, gsize len) { pd->cmd_list[pd->cmd_list_length].icon_fetch_uid = 0; pd->cmd_list[pd->cmd_list_length].icon_fetch_size = 0; pd->cmd_list[pd->cmd_list_length].icon_name = NULL; + pd->cmd_list[pd->cmd_list_length].display = NULL; pd->cmd_list[pd->cmd_list_length].meta = NULL; pd->cmd_list[pd->cmd_list_length].info = NULL; pd->cmd_list[pd->cmd_list_length].active = FALSE; @@ -418,7 +419,11 @@ static char *dmenu_get_completion_data(const Mode *data, unsigned int index) { Mode *sw = (Mode *)data; DmenuModePrivateData *pd = (DmenuModePrivateData *)mode_get_private_data(sw); DmenuScriptEntry *retv = (DmenuScriptEntry *)pd->cmd_list; - return dmenu_format_output_string(pd, retv[index].entry, index, FALSE); + if (retv[index].display) { + return dmenu_format_output_string(pd, retv[index].display, index, FALSE); + } else { + return dmenu_format_output_string(pd, retv[index].entry, index, FALSE); + } } static char *get_display_data(const Mode *data, unsigned int index, int *state, @@ -454,10 +459,16 @@ static char *get_display_data(const Mode *data, unsigned int index, int *state, if (pd->cmd_list[index].active) { *state |= ACTIVE; } - char *my_retv = - (get_entry ? dmenu_format_output_string(pd, retv[index].entry, index, - pd->multi_select) - : NULL); + char *my_retv = NULL; + if (retv[index].display) { + my_retv = (get_entry ? dmenu_format_output_string(pd, retv[index].display, + index, pd->multi_select) + : NULL); + } else { + my_retv = (get_entry ? dmenu_format_output_string(pd, retv[index].entry, + index, pd->multi_select) + : NULL); + } return my_retv; } @@ -472,6 +483,7 @@ static void dmenu_mode_free(Mode *sw) { if (pd->cmd_list[i].entry) { g_free(pd->cmd_list[i].entry); g_free(pd->cmd_list[i].icon_name); + g_free(pd->cmd_list[i].display); g_free(pd->cmd_list[i].meta); g_free(pd->cmd_list[i].info); } diff --git a/source/modes/script.c b/source/modes/script.c index 2bf602868..dfd5bf321 100644 --- a/source/modes/script.c +++ b/source/modes/script.c @@ -92,6 +92,8 @@ void dmenuscript_parse_entry_extras(G_GNUC_UNUSED Mode *sw, *(extra + 1) = NULL; if (strcasecmp(key, "icon") == 0) { entry->icon_name = value; + } else if (strcasecmp(key, "display") == 0) { + entry->display = value; } else if (strcasecmp(key, "meta") == 0) { entry->meta = value; } else if (strcasecmp(key, "info") == 0) { @@ -242,6 +244,7 @@ static DmenuScriptEntry *execute_executor(Mode *sw, char *arg, retv[(*length)].entry = g_memdup(buffer, buf_length); #endif retv[(*length)].icon_name = NULL; + retv[(*length)].display = NULL; retv[(*length)].meta = NULL; retv[(*length)].info = NULL; retv[(*length)].active = FALSE; @@ -355,6 +358,7 @@ static ModeMode script_mode_result(Mode *sw, int mretv, char **input, for (unsigned int i = 0; i < rmpd->cmd_list_length; i++) { g_free(rmpd->cmd_list[i].entry); g_free(rmpd->cmd_list[i].icon_name); + g_free(rmpd->cmd_list[i].display); g_free(rmpd->cmd_list[i].meta); g_free(rmpd->cmd_list[i].info); } @@ -386,6 +390,7 @@ static void script_mode_destroy(Mode *sw) { for (unsigned int i = 0; i < rmpd->cmd_list_length; i++) { g_free(rmpd->cmd_list[i].entry); g_free(rmpd->cmd_list[i].icon_name); + g_free(rmpd->cmd_list[i].display); g_free(rmpd->cmd_list[i].meta); } g_free(rmpd->cmd_list); @@ -437,7 +442,11 @@ static char *_get_display_value(const Mode *sw, unsigned int selected_line, if (pd->do_markup) { *state |= MARKUP; } - return get_entry ? g_strdup(pd->cmd_list[selected_line].entry) : NULL; + if (pd->cmd_list[selected_line].display) { + return get_entry ? g_strdup(pd->cmd_list[selected_line].display) : NULL; + } else { + return get_entry ? g_strdup(pd->cmd_list[selected_line].entry) : NULL; + } } static int script_token_match(const Mode *sw, rofi_int_matcher **tokens, diff --git a/source/rofi-icon-fetcher.c b/source/rofi-icon-fetcher.c index c4243c599..3df9b5090 100644 --- a/source/rofi-icon-fetcher.c +++ b/source/rofi-icon-fetcher.c @@ -360,7 +360,8 @@ static void rofi_icon_fetcher_worker(thread_state *sdata, GdkPixbuf *pb = gdk_pixbuf_new_from_file_at_scale( icon_path, sentry->wsize, sentry->hsize, TRUE, &error); if (error != NULL) { - g_warning("Failed to load image: %s", error->message); + g_error("Failed to load image: |%s| %d %d %s (%p)", icon_path, + sentry->wsize, sentry->hsize, error->message, pb); g_error_free(error); if (pb) { g_object_unref(pb); From 90edb60c4f7f330c6b0340019fbfc9b88b302068 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Fri, 10 Nov 2023 14:41:48 +0100 Subject: [PATCH 12/28] [Script] Add clarification to theme property. --- doc/rofi-script.5 | 5 +++++ doc/rofi-script.5.markdown | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/doc/rofi-script.5 b/doc/rofi-script.5 index 3882f8cb5..8f20b9c6b 100644 --- a/doc/rofi-script.5 +++ b/doc/rofi-script.5 @@ -150,6 +150,11 @@ a widget. .RE +.PP +The \fBtheme\fP property cannot change the interface while running, it is only +usable for small changes in for example background colors of widgets like the +row color of the listview. + .SH Parsing row options .PP Extra options for individual rows can be set. The extra option can be specified diff --git a/doc/rofi-script.5.markdown b/doc/rofi-script.5.markdown index 8d87afc20..963b18555 100644 --- a/doc/rofi-script.5.markdown +++ b/doc/rofi-script.5.markdown @@ -118,6 +118,10 @@ The following extra options exists: - **theme**: Small theme snippet to f.e. change the background color of a widget. +The **theme** property cannot change the interface while running, it is only +usable for small changes in for example background colors of widgets like the +row color of the listview. + ## Parsing row options Extra options for individual rows can be set. The extra option can be specified From 9aaa0a83ee5742d890619439ee9dbec366cfa09b Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Fri, 10 Nov 2023 14:45:26 +0100 Subject: [PATCH 13/28] [Script] Update theme property clarification a bit. --- doc/rofi-script.5 | 4 ++-- doc/rofi-script.5.markdown | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/rofi-script.5 b/doc/rofi-script.5 index 8f20b9c6b..c434f0afb 100644 --- a/doc/rofi-script.5 +++ b/doc/rofi-script.5 @@ -152,8 +152,8 @@ a widget. .PP The \fBtheme\fP property cannot change the interface while running, it is only -usable for small changes in for example background colors of widgets like the -row color of the listview. +usable for small changes in, for example background color, of widgets that get +updated during display like the row color of the listview. .SH Parsing row options .PP diff --git a/doc/rofi-script.5.markdown b/doc/rofi-script.5.markdown index 963b18555..46391fa45 100644 --- a/doc/rofi-script.5.markdown +++ b/doc/rofi-script.5.markdown @@ -119,8 +119,8 @@ The following extra options exists: a widget. The **theme** property cannot change the interface while running, it is only -usable for small changes in for example background colors of widgets like the -row color of the listview. +usable for small changes in, for example background color, of widgets that get +updated during display like the row color of the listview. ## Parsing row options From 272c1ab231f9749a369c2784080020a2122d85c7 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Fri, 10 Nov 2023 17:47:27 +0100 Subject: [PATCH 14/28] Update releasenotes. --- releasenotes/1.7.6/release-1.7.6.markdown | 228 ++++++++++++++++++++++ 1 file changed, 228 insertions(+) diff --git a/releasenotes/1.7.6/release-1.7.6.markdown b/releasenotes/1.7.6/release-1.7.6.markdown index 93e5c1fc5..122139102 100644 --- a/releasenotes/1.7.6/release-1.7.6.markdown +++ b/releasenotes/1.7.6/release-1.7.6.markdown @@ -94,3 +94,231 @@ Special thanks goes to: * Danny Colin Apologies if I mistyped or missed anybody. + +# Changelog + +* [Script] Update theme property clarification a bit. +* [Script] Add clarification to theme property. +* [Dmenu][Script] Add 'display' row option to override whats displayed. +* [DRun] Allow url field to be searched and fix c/p error (#1914) +* [DRUN] Add {url} to drun-display-format. (#1914) +* [lexer] Add dmenu as enabled option for media type. (#1903) +* [XCB] Make sure that window maker is 0 terminated before usage. + Thanks to Omar Polo and bsdmp +* Fix text color when `cursor-color` is set (#1901) +* [XCB] Try to be smarter with where mouse click started. (#1896) +* [View|Textbox] cleanups to drawing code +* Clip text with extents rectangle + Fonts are not ideal, some characters have mismatch between reported and + painted size. +* [Rofi] Expand cache-dir (#1892) +* Fix typos in dmenu docs (#1891) +* Support single quotes for strings as in CSS +* [Theme] Fix missing doxygen documentation +* [Theme] Fix opening abs path if no/wrong extension (backward comp.) +* [rofi-theme] fix typo +* [Theme] Try to fix importing of theme. + - Fix the two place of resolving into one method. + - Do not accept file in CWD. + - Prefer file if it exists in same directory as parent file that + imported it. + (#1889) +* script: Let script handle empty custom input +* widget_draw: clean useless calls in corner drawing +* Fix border segments stitch +* Fix mm type in description +* Remaining modi words in the code +* Better descriptions for sort options group + It's unobvious from documentation, that sort only works against filtered menu. +* update man pages without scripts +* [Lexer] Print some more debug info on error. (#1865) +* [Script] Set type on Mode object. +* [window] Quick test of code scanning. +* [ROFI] -e '-' reads from stdin +* [ConfigParser] Don't pass commandline options with very long args. + This is a quick 'n dirty fix for this unexpected issue. + (#1855) +* [Build] Fix autotools build system. +* [Doc] Fix some missing/wrong doxygen headers. +* Print window manager in -help output +* Merging in the Recursive file browser. +* Add wezterm to rofi-sensible-terminal (#1838) +* [DRun] Add option to scan desktop directory for desktop files. +* [IconFetcher] Fix small memory leak. +* Small memory leaks fixed and other cleanups. +* [MKDocs] Add logo +* [DMenu] Fix row initial tab if non-first column is shown first. (#1834) +* [Doc] Update theme manpage with remark-lint hints. +* [Doc] More small markdown fixes. +* [DOC] Update rofi-script update with remark-lint remarks. +* Remove unneeded test and extra enforcement of 0 terminated buffer +* [Doc] Update rofi.1.markdown with markdown fixes. +* [DOC] update readme.md with remark-lint updates.. +* [DOC] Update INSTALL,md with remark-lint fixes. +* [DOC] Add some remark markdown fixes. +* Fix to pointless or's. +* [UnitTest] Add more tests for environment parsing. +* [Doc] Mention location of scripts in manpage. +* Re-indent the code using clang-format +* Fix typo in template. +* Update issue template to include checkbox for version. +* [Doc] Re-generate manpage +* docs: element children theming (#1818) +* Add support for adding textbox widgets to listview elements (#1792) +* [Textbox] cairo_save/restore does not store path. + Fix by moving cairo_move_to to after blink. + Also fix drawing outline. +* More Unicode normalization with `-normalize-match` (#1813) + Normalize the string to a fully decomposed form, then filter out mark/accent characters. +* #1802: Calc broken fix (#1803) + * [Theme] First move to double internal calculations. + * [Theme] Allow float numbers. + * [Theme] Fix unary - and tighten the grammar parser. + * [Theme] Rename % to modulo to fix compiler. + * [Theme] Dump right modulo syntax. + * [Test] add missing end_test + * [Grammar] Allow negative numbers as property value +* [Dmenu] Small fix that disabled async mode when multi-select is enabled. +* [View] Fix wrong bitmask checking. (& not |) +* [rofi-theme-selector] prepend newline before specifying new theme (#1791) + * [rofi-theme-selector] prepend newline before specifying new theme + If the EOF is not a newline, new theme setting will fail. + * make sed substitution more readable + * simplify sed substitution +* [MKDocs] Try to fix link. +* [MKDocs] Add downloads to side menu +* [MKDocs] Add a download page. +* [Script] Strip pango markup when matching rows (#1795) +* [Doc] theme, spelling fix and more textual tweaks. +* [Doc] More tweaks to get the formulation right. +* [Doc] themes manpage, small textual improvement. +* [Doc] Try to fix some markdown, themes. +* [Doc] Try to clarify the children situation for the listview widget. +* [EntryHistory] Disable entry history when dmenu password is set. +* I785 (#1789) + * [Textbox] Add history to the entrybox. + * [Textbox] Add comments and move into sub functions. + * [doc] Add conflicting constraint section to manpage. + * [Script] Some small memory leak fixes. + * [Entry History] Add documentation. + (#785) +* [doc] Add conflicting constraint section to manpage. +* [mkdoc] add link to user scripts +* [Textbox] Replace 'space' with a space (#1784) +* draw text after cursor (#1777) +* [Doc] Small tweak to markdown. +* [Example] Small change in escaping for caday. +* [Doc] Add manpage documentation for pango font string. +* [MKDocs] Add dynamic theme guide. +* [FileBrowser] Allow command to be overwritten +* [theme] Small theme tweak. +* [Theme] Add NO_IMAGE mode to theme. +* [Themes] add fullscreen theme with preview part. +* [window] When no window title set, handle this more gracefully +* [DMenu|Script] Add per row urgent/active option. + Instead of having a global list of entries to highlight urgent/active, + you can now to it per row. +* sed & realpath workaround for BSD and Darwin OS +* [filebrowser] Add option to return 1 on cancel. (#1732) +* [Theme] Small tweak to fancy2 theme +* [MKDocs] Link to rasi files in theme page. +* [Themes] Add fancy2 theme. +* [Themes] Add material theme +* Fix header theme +* [Helper] Quick fix for wrong dereference. +* MKDoc website (#1772) + * Add initial documentation page using mkdocs + * Test action + * Add notes to mkdoc site. + * Add installation guide + * Add installation and config guide to mkdocs. + * Add installation manual + * Add image to main page + * [mkdocs] Add plugin guide. + * [mkdocs] Add plugin to main page and some small fixes. + * Add shipped themes page + * [actions] Also rebuild website on the next branch +* [themes] don't use screenshot transparency in shipped themes +* [IconFetcher] Fix for api change +* [Theme] support rasinc for theme include files. +* [listview] Don't calculate infinite rows on empty height. (#1769) +* [Theme] Move some definitions header around for plugin. +* [Textbox] Cursor goes over, not under. allow cursor outline. +* [Textbox] Add text-outline to style +* [Doc] Clarify documentation on `require-input` further. +* make cursor more customizable by adding cursor-width and cursor-color (#1753) + * make cursor more customizable by adding cursor-width and cursor-color to the theme + * fix placeholder color + * add doc entry + * more documentation +* [XIM] Fix an unitialized value problem. +* [Doc] Add example run command with cgroup support (#1752) +* [Build] Fix test building in makefile. +* [Doc] Add documentation for new functions. +* [Doc] Fix some missing docu. +* [DMenu] Add -ellipsize-mode option. +* [listview] Set ellipsize mode on creation of textbox + So if rows are added, they behave correctily. (#1746) +* Disable imdkit by default +* Build documentation (#1744) + * explain how to pass options to meson + * fix typo in INSTALL.md +* [Build] Use built-in lto option. +* [Window] Fix reloading windowcd from xserver request +* [Build] Add option to build with lto to meson. + Fix error in test. + (#1743) +* [Build] Add option to disable imdkit at compile time. (#1742) +* input method (#1735) + * input method draft + * restoring relese event + * using unused macro, removing debug code, handling disconnection + * review fixes, new update_im_window_pos method + * initializing variables correctly + * initializing im pos queue correctly + * ime window positioning + * add widget_get_y_pos() position + * [Build] Update makefile with imdkit + * [CI] Add imdkit as dependency. + * [XCB] rofi_view_paste don't throw warning, print debug. + * [XCB] rofi_view_paste lower 'failed to convert selection' + * [Build] Add minimum version check to imdkit + * new macro XCB_IMDKIT_1_0_3_LOWER + * [Build] Try to support old version of imdkit in meson/makefile. + * [Build] Fix typo in meson.build + * [XIM] Don't set use compound/set use utf8 when on old version. + * [Build] Allow building without imdkit. + * [Doc] Add imdkit to dependency list. +* [Window] Make sure their is a trailing 0 on the workspace strings. (#1739) +* [FileBrowser] Bind kb-delete-entry to toggle show-hidden. +* [Textbox] Add a 'get_cursor_x_pos' function. +* [man] re-gen manpage. +* [DOC] Add parsing row options to dmenu manpage (#1734) +* [Build] Fix icon install path for makefile. (#1733) +* [Window] Small fixes to prefer-icon-theme option + Thanks to Kafva (https://github.com/Kafva) for the original patch. + (#1702) +* [Window] Add -window-prefer-icon-theme option. (#1702) +* [drun] Only pass path on launch, if one is set +* The mode is filebrowser (not file-browser) (#1723) +* [filebrowser] Add an option to show hidden files. (#1716) +* [Doc] Update rofi-keys manpage with unset section +* Add format option to disable padding with space the "window-format" entries (#1715) +* [Script] Split mode string only once on :, allowing : in right part. (#1718) +* [window] Check bitmask, not full comparison +* Use `command -v` instead of `which` (#1704) +* [Keyb] Add a -list-keybindings command. +* Fix sed binary call with variable (#1707) +* [listview] Add extra checks before resolving pointer. (#1703) +* [Textbox] Add 'placeholder-markup' flag. (#1690) +* [Test][Theme] Update test for downgrade error +* [Theme] If no theme loaded, load default. Downgrade missing theme file to warning. (#1689) +* [DMenu] reset variable correctly so keep-selection is initially off. (#1686) +* Update test for # keybindings. +* [View|Xcb] Add support to copy current selected item to clipboard (#378) +* Include sys/stat.h for S_IWUSR (#1685) +* [View] Tweak error message and instant/delayed switching. +* [View] Change refilter timeout limit to be in time units (ms) (#1683) +* [Combi] Fix possible memory leak. +* [combi] Fix selecting entry with only bang as input. +* [View] Increase default refilter-timeout-limit. (#1683) From 24c325837969d2ba97ebab0e5b1dcb9e3b756e30 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Thu, 16 Nov 2023 15:25:40 +0100 Subject: [PATCH 15/28] [IconFetcher] If last step fails to load icon, don't error out make warning --- source/rofi-icon-fetcher.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/rofi-icon-fetcher.c b/source/rofi-icon-fetcher.c index 3df9b5090..c65463aee 100644 --- a/source/rofi-icon-fetcher.c +++ b/source/rofi-icon-fetcher.c @@ -360,8 +360,8 @@ static void rofi_icon_fetcher_worker(thread_state *sdata, GdkPixbuf *pb = gdk_pixbuf_new_from_file_at_scale( icon_path, sentry->wsize, sentry->hsize, TRUE, &error); if (error != NULL) { - g_error("Failed to load image: |%s| %d %d %s (%p)", icon_path, - sentry->wsize, sentry->hsize, error->message, pb); + g_warning("Failed to load image: |%s| %d %d %s (%p)", icon_path, + sentry->wsize, sentry->hsize, error->message, pb); g_error_free(error); if (pb) { g_object_unref(pb); From b43a82f86d0cf30e0c7f6d70fbbaa818a617d0be Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Fri, 24 Nov 2023 12:26:24 +0100 Subject: [PATCH 16/28] [View] Always forward motion to the grabbed widget first. --- source/view.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/view.c b/source/view.c index f5102a759..6d04503f5 100644 --- a/source/view.c +++ b/source/view.c @@ -1944,8 +1944,13 @@ void rofi_view_trigger_action(RofiViewState *state, BindingsScope scope, case SCOPE_MOUSE_SCROLLBAR: case SCOPE_MOUSE_MODE_SWITCHER: { gint x = state->mouse.x, y = state->mouse.y; - widget *target = widget_find_mouse_target(WIDGET(state->main_window), - (WidgetType)scope, x, y); + // If we already captured a motion, always forward action to this widget. + widget *target = state->mouse.motion_target; + // If we have not a previous captured motion, lookup widget. + if (target == NULL) { + target = widget_find_mouse_target(WIDGET(state->main_window), + (WidgetType)scope, x, y); + } if (target == NULL) { return; } From d042e20fff6f0dcd3a3d458aba9979e4671642d6 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Fri, 8 Dec 2023 13:51:04 +0100 Subject: [PATCH 17/28] [View] Allow float delay fixes: #1926 --- source/view.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/view.c b/source/view.c index 6d04503f5..0e924c92f 100644 --- a/source/view.c +++ b/source/view.c @@ -555,6 +555,13 @@ static void rofi_view_set_user_timeout(G_GNUC_UNUSED gpointer data) { int delay = p->value.i; CacheState.user_timeout = g_timeout_add(delay * 1000, rofi_view_user_timeout, NULL); + } else { + Property *p = rofi_theme_find_property(wid, P_DOUBLE, "delay", TRUE); + if (p != NULL && p->type == P_DOUBLE && p->value.f > 0.01) { + double delay = p->value.f; + CacheState.user_timeout = + g_timeout_add(delay * 1000, rofi_view_user_timeout, NULL); + } } } } From 11d801ea9e3fbe8579ebc9ff3133eefb85719fa7 Mon Sep 17 00:00:00 2001 From: Qball Cow Date: Sun, 17 Dec 2023 17:26:34 +0100 Subject: [PATCH 18/28] [View] On mode switch force refilter instead of queuing. issue: #1928 --- source/view.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/view.c b/source/view.c index 0e924c92f..4b32cb8e9 100644 --- a/source/view.c +++ b/source/view.c @@ -2709,7 +2709,7 @@ void rofi_view_switch_mode(RofiViewState *state, Mode *mode) { rofi_view_restart(state); state->reload = TRUE; state->refilter = TRUE; - rofi_view_refilter(state); + rofi_view_refilter_force(state); rofi_view_update(state, TRUE); } From 1a5e9e9af61d10071db431444c77a0df7d8ea421 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Thu, 4 Jan 2024 11:26:07 +0100 Subject: [PATCH 19/28] [Doc] Update manpage to clarify meta property. --- doc/rofi-script.5 | 6 +++--- doc/rofi-script.5.markdown | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/rofi-script.5 b/doc/rofi-script.5 index c434f0afb..a09e2decf 100644 --- a/doc/rofi-script.5 +++ b/doc/rofi-script.5 @@ -179,14 +179,14 @@ The following options are supported: .IP \(bu 2 \fBicon\fP: Set the icon for that row. .IP \(bu 2 -\fBdisplay\fP: Replace the displayed string. (Original string will still be used for searching) +\fBdisplay\fP: Replace the displayed string. (Original string will still be used for filtering) .IP \(bu 2 -\fBmeta\fP: Specify invisible search terms. +\fBmeta\fP: Specify invisible search terms used for filtering. .IP \(bu 2 \fBnonselectable\fP: If true the row cannot activated. .IP \(bu 2 \fBinfo\fP: Info that, on selection, gets placed in the \fB\fCROFI_INFO\fR -environment variable. This entry does not get searched. +environment variable. This entry does not get searched for filtering. .IP \(bu 2 \fBurgent\fP: Set urgent flag on entry (true/false) .IP \(bu 2 diff --git a/doc/rofi-script.5.markdown b/doc/rofi-script.5.markdown index 46391fa45..03df5bc92 100644 --- a/doc/rofi-script.5.markdown +++ b/doc/rofi-script.5.markdown @@ -137,14 +137,14 @@ The following options are supported: - **icon**: Set the icon for that row. -- **display**: Replace the displayed string. (Original string will still be used for searching) +- **display**: Replace the displayed string. (Original string will still be used for filtering) -- **meta**: Specify invisible search terms. +- **meta**: Specify invisible search terms used for filtering. - **nonselectable**: If true the row cannot activated. - **info**: Info that, on selection, gets placed in the `ROFI_INFO` - environment variable. This entry does not get searched. + environment variable. This entry does not get searched for filtering. - **urgent**: Set urgent flag on entry (true/false) From e74c2dc25334fb099d4a19240a7a9d2b4839da60 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Tue, 9 Jan 2024 11:46:25 +0100 Subject: [PATCH 20/28] [DOC] Add explanation to PATTERN of brackets Fixes: #1933 --- doc/rofi.1 | 9 +++++++++ doc/rofi.1.markdown | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/doc/rofi.1 b/doc/rofi.1 index 022310aea..6d4c10e93 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -1340,6 +1340,15 @@ replaced at runtime: .RE +.PP +It processes the string as follows: \fB\fC{key}\fR +is replaced by its value, if \fB\fC{key}\fR is not set it is removed. If the \fB\fC{key}\fR +is in between \fB\fC[]\fR all the text between \fB\fC[]\fR is removed if \fB\fC{key}\fR is not set. +Otherwise key is replaced and the \fB\fC[]\fR are removed. + +.PP +For example: \fB\fC{ssh-client} [-p {port}] {host}\fR + .SH THEMING .PP Please see \fBrofi-theme(5)\fP manpage for more information on theming. diff --git a/doc/rofi.1.markdown b/doc/rofi.1.markdown index 0f9c3cb60..67e3e0e55 100644 --- a/doc/rofi.1.markdown +++ b/doc/rofi.1.markdown @@ -880,6 +880,13 @@ replaced at runtime: - `{cmd}`: the command to execute - `{window}`: the window ID of the selected window (in `window-command`) +It processes the string as follows: `{key}` +is replaced by its value, if `{key}` is not set it is removed. If the `{key}` +is in between `[]` all the text between `[]` is removed if `{key}` is not set. +Otherwise key is replaced and the `[]` are removed. + +For example: `{ssh-client} [-p {port}] {host}` + ## THEMING Please see **rofi-theme(5)** manpage for more information on theming. From 689d72f1dc6ccefd5d6d5179b9b72b3844fb2c4f Mon Sep 17 00:00:00 2001 From: Igor <420spn@gmail.com> Date: Mon, 29 Jan 2024 21:29:52 +0600 Subject: [PATCH 21/28] Fix typo in dynamic_themes.md (#1941) Add missing "P" in "PREVIEW=true" --- mkdocs/docs/guides/DynamicThemes/dynamic_themes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs/docs/guides/DynamicThemes/dynamic_themes.md b/mkdocs/docs/guides/DynamicThemes/dynamic_themes.md index ca0999331..ee2822233 100644 --- a/mkdocs/docs/guides/DynamicThemes/dynamic_themes.md +++ b/mkdocs/docs/guides/DynamicThemes/dynamic_themes.md @@ -170,7 +170,7 @@ These will be merged into the theme on load: Now if we run it: ```bash -REVIEW=true rofi -theme fullscreen-preview.rasi -show filebrowser +PREVIEW=true rofi -theme fullscreen-preview.rasi -show filebrowser ``` It looks like this: From 1c7ff16add6b52de908f00731c0fc07b100ed994 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sat, 10 Feb 2024 21:36:27 +0100 Subject: [PATCH 22/28] Add extra documentation issue template. --- .../ISSUE_TEMPLATE/documentation_report.yml | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/documentation_report.yml diff --git a/.github/ISSUE_TEMPLATE/documentation_report.yml b/.github/ISSUE_TEMPLATE/documentation_report.yml new file mode 100644 index 000000000..3ca06d51a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation_report.yml @@ -0,0 +1,81 @@ +name: Documentation Bug Report +description: Report a problem in Rofi Documentation +labels: [Documentation] +title: "[Doc] " +body: + + - type: markdown + attributes: + value: | + First read the + [guidelines](https://github.com/DaveDavenport/rofi/blob/next/.github/CONTRIBUTING.md)! + This is not optional for any report. People must be able to understand + the full context of the report when reading it, at any time. + + If you feel like you “it is simple and requires no explanation”, please + consider you’re wrong and still fill the full report. Any report + missing required informations will be labeled as “Incomplete Report - + Please follow the guidelines” and will be closed. If you ask a + question, enter dummy information in required fields to get passed the + checks or in general completely ignore the guidelines, the issue will + be closed and locked as spam. + + If you are unsure, please use the + [discussion](https://github.com/davatorium/rofi/discussions) forum + first. It is easy to upgrade a question to an issue in github. + + **Please do not submit reports related to wayland, see + [here](https://github.com/DaveDavenport/rofi/wiki/Wayland) for more + information.** + + - type: input + attributes: + label: "Rofi version (rofi -v)" + placeholder: "Version: 1.7.5" + validations: + required: true + - type: input + attributes: + label: "URL" + description: "Please provide a link to the relevant documentation." + placeholder: "link to page on https://davatorium.github.io/rofi/ or file on https://github.com/davatorium/rofi/" + validations: + required: true + + - type: textarea + attributes: + label: "Explain the issue with the documentation, please be verbose." + placeholder: | + * What am I trying to achieve + .. + * What instructions are unclear, wrong or missing + .. + * Suggestions for improving the current documentation + .. + validations: + required: true + - type: textarea + attributes: + label: "Optional fixed text" + description: "Suggested new and or improved text for documentation." + validations: + required: false + - type: checkboxes + id: wayland + attributes: + label: Using wayland display server protocol + description: I have checked and confirm that my issue is not related to running rofi using wayland as display server protocol. See [here](https://github.com/DaveDavenport/rofi/wiki/Wayland) for more information. + options: + - label: "No, my documentation issue is not about running rofi using the wayland display server protocol" + required: true + - type: checkboxes + id: latestversion + attributes: + label: I've checked if the issue exists in the latest stable release + description: I confirm that I verified the issue still exists in the latest stable release. + options: + - label: "Yes, I have checked the problem exists in the latest stable version" + required: false + + + From c3023b399bdd7b5fbba4860743c6ef389be97536 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sat, 10 Feb 2024 21:41:40 +0100 Subject: [PATCH 23/28] [Doc] Clarify in build instructions what release to use. --- INSTALL.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/INSTALL.md b/INSTALL.md index 0a8870d67..1a35bdec2 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -70,6 +70,11 @@ On debian based systems, the developer packages are in the form of: ## Install from a release +When downloading from the github release page, make sure to grab the archive +`rofi-{version}.tar.[g|x]z`. The auto-attached files `source code (zip|tar.gz)` +by github do not contain a valid release. It misses a setup build system and +includes irrelevant files. + ### Autotools Create a build directory and enter it: From dc43ee7d5b379363cba2f0377e7119822e8fb866 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sat, 10 Feb 2024 21:52:20 +0100 Subject: [PATCH 24/28] [Doc] Remove reddit link from config.yml. --- .github/ISSUE_TEMPLATE/config.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index afff87bf9..8d179ff8c 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -3,9 +3,6 @@ contact_links: - name: discussion forum url: https://github.com/davatorium/rofi/discussions about: Please ask and answer questions here. - - name: Rofi subreddit - url: https://www.reddit.com/r/qtools/ - about: Please ask and answer questions here. - name: Rofi IRC channel url: https://web.libera.chat/?channels=#rofi about: Please ask and answer question in real time here. From 3dc3e2d6164ab4a8720d044575a09d43f06eab0d Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sat, 10 Feb 2024 22:14:08 +0100 Subject: [PATCH 25/28] [Doc] Fix broken ``` guards. --- INSTALL.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 1a35bdec2..38da5508b 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -257,19 +257,19 @@ For more information see the rofi-debugging(5) manpage. ```bash apt install rofi -```` +``` ### Fedora ```bash dnf install rofi -```` +``` ### ArchLinux ```bash pacman -S rofi -```` +``` ### Gentoo @@ -278,13 +278,13 @@ enable ~arch to get the latest release: ```bash echo 'x11-misc/rofi ~amd64' >> /etc/portage/package.accept_keywords -```` +``` for amd64 or: ```bash echo 'x11-misc/rofi ~x86' >> /etc/portage/package.accept_keywords -```` +``` for i386. @@ -296,13 +296,13 @@ On both openSUSE Leap and openSUSE Tumbleweed rofi can be installed using: ```bash sudo zypper install rofi -```` +``` ### FreeBSD ```bash sudo pkg install rofi -```` +``` ### macOS From 13c2a617666d5ee054fee2bba6abc3ce6a557570 Mon Sep 17 00:00:00 2001 From: Qball Cow Date: Sun, 11 Feb 2024 13:59:11 +0100 Subject: [PATCH 26/28] [ThreadPool] Sort items in the queue based on priority --- include/rofi-types.h | 1 + source/rofi-icon-fetcher.c | 2 ++ source/view.c | 11 +++++++++++ 3 files changed, 14 insertions(+) diff --git a/include/rofi-types.h b/include/rofi-types.h index 4fc878d4a..4fdb3e37b 100644 --- a/include/rofi-types.h +++ b/include/rofi-types.h @@ -370,6 +370,7 @@ typedef struct rofi_int_matcher_t { */ typedef struct _thread_state { void (*callback)(struct _thread_state *t, gpointer data); + int priority; } thread_state; extern GThreadPool *tpool; diff --git a/source/rofi-icon-fetcher.c b/source/rofi-icon-fetcher.c index c65463aee..c2bb0f1f4 100644 --- a/source/rofi-icon-fetcher.c +++ b/source/rofi-icon-fetcher.c @@ -411,6 +411,7 @@ uint32_t rofi_icon_fetcher_query_advanced(const char *name, const int wsize, // Push into fetching queue. sentry->state.callback = rofi_icon_fetcher_worker; + sentry->state.priority = G_PRIORITY_LOW; g_thread_pool_push(tpool, sentry, NULL); return sentry->uid; @@ -447,6 +448,7 @@ uint32_t rofi_icon_fetcher_query(const char *name, const int size) { // Push into fetching queue. sentry->state.callback = rofi_icon_fetcher_worker; + sentry->state.priority = G_PRIORITY_LOW; g_thread_pool_push(tpool, sentry, NULL); return sentry->uid; diff --git a/source/view.c b/source/view.c index 4b32cb8e9..29ca23073 100644 --- a/source/view.c +++ b/source/view.c @@ -1444,6 +1444,7 @@ static gboolean rofi_view_refilter_real(RofiViewState *state) { states[i].plen = plen; states[i].pattern = pattern; states[i].st.callback = filter_elements; + states[i].st.priority = G_PRIORITY_HIGH; if (i > 0) { g_thread_pool_push(tpool, &states[i], NULL); } @@ -2624,6 +2625,15 @@ void rofi_view_cleanup() { input_history_save(); } + +static int rofi_thread_workers_sort(gconstpointer a,gconstpointer b, gpointer data G_GNUC_UNUSED) +{ + thread_state *tsa = (thread_state *)a; + thread_state *tsb = (thread_state *)b; + // lower number is lower priority.. a is sorted above is a > b. + return tsa->priority-tsb->priority; +} + void rofi_view_workers_initialize(void) { TICK_N("Setup Threadpool, start"); if (config.threads == 0) { @@ -2649,6 +2659,7 @@ void rofi_view_workers_initialize(void) { g_error_free(error); exit(EXIT_FAILURE); } + g_thread_pool_set_sort_function(tpool, rofi_thread_workers_sort, NULL); TICK_N("Setup Threadpool, done"); } void rofi_view_workers_finalize(void) { From 831bddc68b79c58044dbfeb2be62f77948e1726b Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Thu, 15 Feb 2024 09:13:37 +0100 Subject: [PATCH 27/28] [Box] When estimating height, set correct width on children Issue: #1943 --- source/widgets/box.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/widgets/box.c b/source/widgets/box.c index 3a5c49d49..e0425b8e3 100644 --- a/source/widgets/box.c +++ b/source/widgets/box.c @@ -96,6 +96,7 @@ static int box_get_desired_height(widget *wid, const int width) { box *b = (box *)wid; int spacing = distance_get_pixel(b->spacing, b->type); int height = 0; + int nw = width - widget_padding_get_padding_width(wid); if (b->type == ROFI_ORIENTATION_VERTICAL) { int active_widgets = 0; for (GList *iter = g_list_first(b->children); iter != NULL; @@ -105,7 +106,7 @@ static int box_get_desired_height(widget *wid, const int width) { continue; } active_widgets++; - height += widget_get_desired_height(child, width); + height += widget_get_desired_height(child, nw); } if (active_widgets > 0) { height += (active_widgets - 1) * spacing; @@ -117,7 +118,7 @@ static int box_get_desired_height(widget *wid, const int width) { if (!child->enabled) { continue; } - height = MAX(widget_get_desired_height(child, width), height); + height = MAX(widget_get_desired_height(child, nw), height); } } height += widget_padding_get_padding_height(wid); From 3a5f95d69e0a3d2bd20a247882ba4c30cdf0b845 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Fri, 16 Feb 2024 13:36:21 +0100 Subject: [PATCH 28/28] [View] Don't use xcb surface to render to png, but create surface. --- source/view.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/source/view.c b/source/view.c index 29ca23073..fe438daee 100644 --- a/source/view.c +++ b/source/view.c @@ -217,13 +217,13 @@ static int lev_sort(const void *p1, const void *p2, void *arg) { /** * Stores a screenshot of Rofi at that point in time. */ -void rofi_capture_screenshot(void) { - const char *outp = g_getenv("ROFI_PNG_OUTPUT"); - if (CacheState.edit_surf == NULL) { - // Nothing to store. - g_warning("There is no rofi surface to store"); +void rofi_capture_screenshot() { + RofiViewState *state = current_active_menu; + if (state == NULL || state->main_window == NULL) { + g_warning("Nothing to screenshot."); return; } + const char *outp = g_getenv("ROFI_PNG_OUTPUT"); const char *xdg_pict_dir = g_get_user_special_dir(G_USER_DIRECTORY_PICTURES); if (outp == NULL && xdg_pict_dir == NULL) { g_warning("XDG user picture directory or ROFI_PNG_OUTPUT is not set. " @@ -254,12 +254,30 @@ void rofi_capture_screenshot(void) { fpath = g_strdup(outp); } fprintf(stderr, color_green "Storing screenshot %s\n" color_reset, fpath); - cairo_status_t status = - cairo_surface_write_to_png(CacheState.edit_surf, fpath); + cairo_surface_t *surf = cairo_image_surface_create( + CAIRO_FORMAT_ARGB32, state->width, state->height); + cairo_status_t status = cairo_surface_status(surf); if (status != CAIRO_STATUS_SUCCESS) { g_warning("Failed to produce screenshot '%s', got error: '%s'", fpath, cairo_status_to_string(status)); + } else { + cairo_t *draw = cairo_create(surf); + status = cairo_status(draw); + if (status != CAIRO_STATUS_SUCCESS) { + g_warning("Failed to produce screenshot '%s', got error: '%s'", fpath, + cairo_status_to_string(status)); + } else { + widget_draw(WIDGET(state->main_window), draw); + status = cairo_surface_write_to_png(surf, fpath); + if (status != CAIRO_STATUS_SUCCESS) { + g_warning("Failed to produce screenshot '%s', got error: '%s'", fpath, + cairo_status_to_string(status)); + } + } + cairo_destroy(draw); } + // Cleanup + cairo_surface_destroy(surf); g_free(fpath); g_free(filename); g_free(timestmp);