[DMenu] If input is stdin and from a tty, do not read data.

- This stops rofi from blocking the whole desktop.
This commit is contained in:
Dave Davenport 2017-07-17 15:01:02 +02:00
parent b5a1ba16e2
commit 2060059c46
1 changed files with 17 additions and 12 deletions

View File

@ -451,11 +451,13 @@ static int dmenu_mode_init ( Mode *sw )
}
g_free ( estr );
}
pd->cancel = g_cancellable_new ();
pd->cancel_source = g_cancellable_connect ( pd->cancel, G_CALLBACK ( async_read_cancel ), pd, NULL );
pd->input_stream = g_unix_input_stream_new ( fd, fd != STDIN_FILENO );
pd->data_input_stream = g_data_input_stream_new ( pd->input_stream );
// If input is stdin, and a tty, do not read as rofi grabs input and therefor blocks.
if ( ! ( fd == STDIN_FILENO && isatty ( fd ) == 1 ) ) {
pd->cancel = g_cancellable_new ();
pd->cancel_source = g_cancellable_connect ( pd->cancel, G_CALLBACK ( async_read_cancel ), pd, NULL );
pd->input_stream = g_unix_input_stream_new ( fd, fd != STDIN_FILENO );
pd->data_input_stream = g_data_input_stream_new ( pd->input_stream );
}
gchar *columns = NULL;
if ( find_arg_str ( "-display-columns", &columns ) ) {
pd->columns = g_strsplit ( columns, ",", 0 );
@ -663,13 +665,16 @@ int dmenu_switcher_dialog ( void )
find_arg ( "-selected-row" ) >= 0 ) {
async = FALSE;
}
if ( async ) {
unsigned int pre_read = 25;
find_arg_uint ( "-async-pre-read", &pre_read );
async = get_dmenu_async ( pd, pre_read );
}
else {
get_dmenu_sync ( pd );
// Check if the subsystem is setup for reading, otherwise do not read.
if ( pd->cancel != NULL ) {
if ( async ) {
unsigned int pre_read = 25;
find_arg_uint ( "-async-pre-read", &pre_read );
async = get_dmenu_async ( pd, pre_read );
}
else {
get_dmenu_sync ( pd );
}
}
char *input = NULL;
unsigned int cmd_list_length = pd->cmd_list_length;