diff options
-rw-r--r-- | source/dialogs/dmenu.c | 49 | ||||
-rw-r--r-- | source/view.c | 22 |
2 files changed, 33 insertions, 38 deletions
diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c index 4bebf99c..cd10dac5 100644 --- a/source/dialogs/dmenu.c +++ b/source/dialogs/dmenu.c @@ -359,6 +359,22 @@ Mode dmenu_mode = .free = NULL }; +static void dmenu_finish ( RofiViewState *state, int retv) +{ + if ( retv == FALSE ) { + rofi_set_return_code ( EXIT_FAILURE ); + } + else if ( retv >= 10 ) { + rofi_set_return_code ( retv ); + } + else{ + rofi_set_return_code ( EXIT_SUCCESS ); + } + rofi_view_set_active ( NULL ); + rofi_view_free ( state ); + mode_destroy ( &dmenu_mode ); +} + static void dmenu_finalize ( RofiViewState *state ) { int retv = FALSE; @@ -390,22 +406,9 @@ static void dmenu_finalize ( RofiViewState *state ) retv = TRUE; if ( ( mretv & MENU_QUICK_SWITCH ) ) { retv = 10 + ( mretv & MENU_LOWER_MASK ); - } - rofi_view_free ( state ); + } g_free ( input ); - mode_destroy ( &dmenu_mode ); - if ( retv == FALSE ) { - rofi_set_return_code ( EXIT_FAILURE ); - } - else if ( retv >= 10 ) { - rofi_set_return_code ( retv ); - } - else{ - rofi_set_return_code ( EXIT_SUCCESS ); - } - rofi_view_free ( state ); - mode_destroy ( &dmenu_mode ); - rofi_view_set_active ( NULL ); + dmenu_finish(state, retv); return; } pd->selected_line = next_pos - 1; @@ -413,6 +416,9 @@ static void dmenu_finalize ( RofiViewState *state ) // Restart rofi_view_restart ( state ); rofi_view_set_selected_line ( state, pd->selected_line ); + if ( !restart ) { + dmenu_finish(state, retv); + } return; } // We normally do not want to restart the loop. @@ -473,18 +479,7 @@ static void dmenu_finalize ( RofiViewState *state ) rofi_view_set_selected_line ( state, pd->selected_line ); } else { - if ( retv == FALSE ) { - rofi_set_return_code ( EXIT_FAILURE ); - } - else if ( retv >= 10 ) { - rofi_set_return_code ( retv ); - } - else{ - rofi_set_return_code ( EXIT_SUCCESS ); - } - rofi_view_free ( state ); - mode_destroy ( &dmenu_mode ); - rofi_view_set_active ( NULL ); + dmenu_finish(state,retv); } } diff --git a/source/view.c b/source/view.c index 2c17d11a..7bebdd8d 100644 --- a/source/view.c +++ b/source/view.c @@ -70,17 +70,17 @@ extern Display *display; extern SnLauncheeContext *sncontext; -GThreadPool *tpool = NULL; - -RofiViewState *current_active_menu = NULL; -Window main_window = None; -cairo_surface_t *surface = NULL; -cairo_surface_t *fake_bg = NULL; -cairo_t *draw = NULL; -XIM xim; -XIC xic; -Colormap map = None; -XVisualInfo vinfo; +GThreadPool *tpool = NULL; + +RofiViewState *current_active_menu = NULL; +Window main_window = None; +cairo_surface_t *surface = NULL; +cairo_surface_t *fake_bg = NULL; +cairo_t *draw = NULL; +XIM xim; +XIC xic; +Colormap map = None; +XVisualInfo vinfo; static char * get_matching_state ( void ) { |