mirror of https://github.com/davatorium/rofi.git
cleanup
This commit is contained in:
parent
ef8d444dd2
commit
0068618573
|
@ -354,10 +354,6 @@ void winlist_free( winlist *l )
|
||||||
free( l->data );
|
free( l->data );
|
||||||
free( l );
|
free( l );
|
||||||
}
|
}
|
||||||
void winlist_empty_2d( winlist *l )
|
|
||||||
{
|
|
||||||
while ( l->len > 0 ) winlist_free( l->data[--( l->len )] );
|
|
||||||
}
|
|
||||||
int winlist_find( winlist *l, Window w )
|
int winlist_find( winlist *l, Window w )
|
||||||
{
|
{
|
||||||
// iterate backwards. theory is: windows most often accessed will be
|
// iterate backwards. theory is: windows most often accessed will be
|
||||||
|
@ -369,23 +365,6 @@ int winlist_find( winlist *l, Window w )
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int winlist_forget( winlist *l, Window w )
|
|
||||||
{
|
|
||||||
int i, j;
|
|
||||||
|
|
||||||
for ( i = 0, j = 0; i < l->len; i++, j++ ) {
|
|
||||||
l->array[j] = l->array[i];
|
|
||||||
l->data[j] = l->data[i];
|
|
||||||
|
|
||||||
if ( l->array[i] == w ) {
|
|
||||||
free( l->data[i] );
|
|
||||||
j--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
l->len -= ( i-j );
|
|
||||||
return j != i ?1:0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define CLIENTTITLE 100
|
#define CLIENTTITLE 100
|
||||||
#define CLIENTCLASS 50
|
#define CLIENTCLASS 50
|
||||||
|
@ -1273,7 +1252,17 @@ void help()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline int program_end()
|
||||||
|
{
|
||||||
|
winlist_free( cache_xattr );
|
||||||
|
winlist_free( cache_client );
|
||||||
|
#ifdef I3
|
||||||
|
|
||||||
|
if ( i3_socket_path != NULL ) free( i3_socket_path );
|
||||||
|
|
||||||
|
#endif
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main( int argc, char *argv[] )
|
int main( int argc, char *argv[] )
|
||||||
|
@ -1357,32 +1346,17 @@ int main( int argc, char *argv[] )
|
||||||
// flags to run immediately and exit
|
// flags to run immediately and exit
|
||||||
if ( find_arg( ac, av, "-now" ) >= 0 ) {
|
if ( find_arg( ac, av, "-now" ) >= 0 ) {
|
||||||
run_switcher( NOFORK, WINDOW_SWITCHER );
|
run_switcher( NOFORK, WINDOW_SWITCHER );
|
||||||
#ifdef I3
|
return program_end();
|
||||||
|
|
||||||
if ( i3_socket_path != NULL ) free( i3_socket_path );
|
|
||||||
|
|
||||||
#endif
|
|
||||||
exit( EXIT_SUCCESS );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( find_arg( ac, av, "-rnow" ) >= 0 ) {
|
if ( find_arg( ac, av, "-rnow" ) >= 0 ) {
|
||||||
run_switcher( NOFORK, RUN_DIALOG );
|
run_switcher( NOFORK, RUN_DIALOG );
|
||||||
#ifdef I3
|
return program_end();
|
||||||
|
|
||||||
if ( i3_socket_path != NULL ) free( i3_socket_path );
|
|
||||||
|
|
||||||
#endif
|
|
||||||
exit( EXIT_SUCCESS );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( find_arg( ac, av, "-snow" ) >= 0 ) {
|
if ( find_arg( ac, av, "-snow" ) >= 0 ) {
|
||||||
run_switcher( NOFORK, SSH_DIALOG );
|
run_switcher( NOFORK, SSH_DIALOG );
|
||||||
#ifdef I3
|
return program_end();
|
||||||
|
|
||||||
if ( i3_socket_path != NULL ) free( i3_socket_path );
|
|
||||||
|
|
||||||
#endif
|
|
||||||
exit( EXIT_SUCCESS );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// in background mode from here on
|
// in background mode from here on
|
||||||
|
@ -1413,10 +1387,5 @@ int main( int argc, char *argv[] )
|
||||||
if ( ev.type == KeyPress ) handle_keypress( &ev );
|
if ( ev.type == KeyPress ) handle_keypress( &ev );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef I3
|
return program_end();
|
||||||
|
|
||||||
if ( i3_socket_path != NULL ) free( i3_socket_path );
|
|
||||||
|
|
||||||
#endif
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,11 +184,18 @@ static char ** get_ssh ( )
|
||||||
|
|
||||||
for ( stop=start; isalnum( buffer[stop] ); stop++ );
|
for ( stop=start; isalnum( buffer[stop] ); stop++ );
|
||||||
|
|
||||||
|
int found = 0;
|
||||||
|
// This is a nice little penalty, but doable? time will tell.
|
||||||
|
// given num_favorites is max 25.
|
||||||
|
for ( int j = 0; found == 0 && j < num_favorites; j++ ) {
|
||||||
|
if ( strncasecmp( &buffer[start], retv[j],stop-start ) == 0 ) found = 1;
|
||||||
|
}
|
||||||
|
if ( found == 1 ) continue;
|
||||||
|
|
||||||
retv = realloc( retv, ( index+2 )*sizeof( char* ) );
|
retv = realloc( retv, ( index+2 )*sizeof( char* ) );
|
||||||
retv[index] = strndup( &buffer[start], stop-start );
|
retv[index] = strndup( &buffer[start], stop-start );
|
||||||
retv[index+1] = NULL;
|
retv[index+1] = NULL;
|
||||||
index++;
|
index++;
|
||||||
num_favorites++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue