1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Add [no]focus restore option.

This commit is contained in:
Dave Davenport 2021-03-27 16:28:27 +01:00
parent 6fc686c50d
commit 750dbad729
7 changed files with 28 additions and 3 deletions

View file

@ -173,5 +173,7 @@ Settings config = {
.benchmark_ui = FALSE,
/** normalize match */
.normalize_match = FALSE
.normalize_match = FALSE,
/** restore focus */
.restore_focus = TRUE
};

View file

@ -442,6 +442,12 @@ Use Pango markup to format output wherever possible.
.PP
Make \fBrofi\fP react like a normal application window. Useful for scripts like Clerk that are basically an application.
.PP
\fB\fC\-[no\-]restore\-focus\fR
.PP
Make rofi restore focus to window that held it when launched.
.SS Matching
.PP
\fB\fC\-matching\fR \fImethod\fP

View file

@ -254,6 +254,10 @@ Use Pango markup to format output wherever possible.
Make **rofi** react like a normal application window. Useful for scripts like Clerk that are basically an application.
`-[no-]restore-focus`
Make rofi restore focus to window that held it when launched.
### Matching
`-matching` *method*

View file

@ -205,6 +205,8 @@ typedef struct
gboolean benchmark_ui;
gboolean normalize_match;
/** Restore focus */
gboolean restore_focus;
} Settings;
/** Global Settings structure. */
extern Settings config;

View file

@ -751,11 +751,15 @@ static void helper_eval_add_str ( GString *str, const char *input, int l, int ma
else {
if ( nc > l ) {
int bl = g_utf8_offset_to_pointer ( input_nn, l ) - input_nn;
g_string_append_len ( str, input_nn, bl );
char *tmp = g_regex_escape_string(input_nn, bl);
g_string_append ( str, tmp );
g_free(tmp);
}
else {
spaces = l - nc;
g_string_append ( str, input_nn );
char *tmp = g_regex_escape_string(input_nn, -1);
g_string_append ( str, tmp );
g_free(tmp);
}
}
while ( spaces-- ) {
@ -819,6 +823,7 @@ static char *_get_display_value ( const Mode *sw, unsigned int selected_line, in
if ( c->active ) {
*state |= ACTIVE;
}
*state |= MARKUP;
return get_entry ? _generate_display_string ( rmpd, c ) : NULL;
}

View file

@ -1187,6 +1187,10 @@ static gboolean main_loop_x11_event_handler ( xcb_generic_event_t *ev, G_GNUC_UN
void rofi_xcb_set_input_focus ( xcb_window_t w )
{
if ( config.restore_focus == FALSE ) {
xcb->focus_revert = 0;
return;
}
xcb_generic_error_t *error;
xcb_get_input_focus_reply_t *freply;
xcb_get_input_focus_cookie_t fcookie = xcb_get_input_focus ( xcb->connection );

View file

@ -233,6 +233,8 @@ static XrmOption xrmOptions[] = {
"DRUN: If enabled, reload the cache with desktop file content.", CONFIG_DEFAULT },
{ xrm_Boolean, "normalize-match", { .snum = &config.normalize_match }, NULL,
"Normalize string when matching (implies -no-show-match).", CONFIG_DEFAULT },
{ xrm_Boolean, "restore-focus", { .snum = &config.restore_focus }, NULL,
"Restore focus on close to window that had it on rofi start.", CONFIG_DEFAULT },
};
/** Dynamic array of extra options */