diff options
author | Dave Davenport <qball@gmpclient.org> | 2016-02-19 19:50:48 +0100 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2016-02-19 19:50:48 +0100 |
commit | 6e3bb506de081362d71dc097273fbe954f651056 (patch) | |
tree | e38dd0ba4a0b95eb850e3a4decb1c7f9302f0153 | |
parent | 4eb3fd1da33e91ad76efe1508702de50daf0df34 (diff) |
Full mainloop madness
-rw-r--r-- | include/helper.h | 2 | ||||
-rw-r--r-- | include/textbox.h | 18 | ||||
-rw-r--r-- | source/dialogs/dmenu.c | 1 | ||||
-rw-r--r-- | source/helper.c | 5 | ||||
-rw-r--r-- | source/rofi.c | 38 | ||||
-rw-r--r-- | source/view.c | 12 |
6 files changed, 37 insertions, 39 deletions
diff --git a/include/helper.h b/include/helper.h index b250604b..0d47762e 100644 --- a/include/helper.h +++ b/include/helper.h @@ -137,7 +137,7 @@ void remove_pid_file ( int fd ); * * This functions exits the program with 1 when it finds an invalid configuration. */ -void config_sanity_check ( Display *display ); +int config_sanity_check ( Display *display ); /** * @param arg string to parse. diff --git a/include/textbox.h b/include/textbox.h index c321eb47..757b1c62 100644 --- a/include/textbox.h +++ b/include/textbox.h @@ -42,15 +42,15 @@ typedef struct typedef enum { - TB_AUTOHEIGHT = 1 << 0, - TB_AUTOWIDTH = 1 << 1, - TB_LEFT = 1 << 16, - TB_RIGHT = 1 << 17, - TB_CENTER = 1 << 18, - TB_EDITABLE = 1 << 19, - TB_MARKUP = 1 << 20, - TB_WRAP = 1 << 21, - TB_PASSWORD = 1 << 22, + TB_AUTOHEIGHT = 1 << 0, + TB_AUTOWIDTH = 1 << 1, + TB_LEFT = 1 << 16, + TB_RIGHT = 1 << 17, + TB_CENTER = 1 << 18, + TB_EDITABLE = 1 << 19, + TB_MARKUP = 1 << 20, + TB_WRAP = 1 << 21, + TB_PASSWORD = 1 << 22, } TextboxFlags; typedef enum diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c index 1c584e53..4bebf99c 100644 --- a/source/dialogs/dmenu.c +++ b/source/dialogs/dmenu.c @@ -406,7 +406,6 @@ static void dmenu_finalize ( RofiViewState *state ) rofi_view_free ( state ); mode_destroy ( &dmenu_mode ); rofi_view_set_active ( NULL ); -// g_main_loop_quit(NULL); return; } pd->selected_line = next_pos - 1; diff --git a/source/helper.c b/source/helper.c index 96eb92e2..b19caf6b 100644 --- a/source/helper.c +++ b/source/helper.c @@ -508,7 +508,7 @@ void remove_pid_file ( int fd ) * * This functions exits the program with 1 when it finds an invalid configuration. */ -void config_sanity_check ( Display *display ) +int config_sanity_check ( Display *display ) { if ( config.threads == 0 ) { config.threads = 1; @@ -591,10 +591,11 @@ void config_sanity_check ( Display *display ) if ( found_error ) { g_string_append ( msg, "Please update your configuration." ); show_error_message ( msg->str, TRUE ); - exit ( EXIT_FAILURE ); + return TRUE; } g_string_free ( msg, TRUE ); + return FALSE; } char *rofi_expand_path ( const char *input ) diff --git a/source/rofi.c b/source/rofi.c index 7f1ce608..a9030451 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -207,6 +207,7 @@ static void run_switcher ( ModeMode mode ) char *input = g_strdup ( config.filter ); __run_switcher_internal ( mode, input ); g_free ( input ); + main_loop_x11_event_handler ( NULL ); } void process_result ( RofiViewState *state ) { @@ -247,7 +248,6 @@ void process_result ( RofiViewState *state ) */ __run_switcher_internal ( mode, input ); g_free ( input ); - main_loop_x11_event_handler ( NULL ); return; } // Cleanup @@ -655,18 +655,32 @@ static gboolean delayed_start ( G_GNUC_UNUSED gpointer data ) static gboolean startup ( G_GNUC_UNUSED gpointer data ) { + TICK_N ( "Startup" ); // flags to run immediately and exit char *sname = NULL; char *msg = NULL; + // + // Sanity check + if ( config_sanity_check ( display ) ) { + return G_SOURCE_REMOVE; + } + TICK_N ( "Config sanity check" ); + // Parse the keybindings. + parse_keys_abe (); + // Check if there is error dialog. + if ( rofi_view_get_active ( ) != NULL ) { + return G_SOURCE_REMOVE; + } + TICK_N ( "Parse ABE" ); // Dmenu mode. if ( dmenu_mode == TRUE ) { // force off sidebar mode: config.sidebar_mode = FALSE; int retv = run_dmenu (); if ( retv ) { - rofi_set_return_code ( EXIT_SUCCESS ); + rofi_set_return_code ( EXIT_SUCCESS ); // Directly exit. - g_main_loop_quit(main_loop); + g_main_loop_quit ( main_loop ); } } else if ( find_arg_str ( "-e", &( msg ) ) ) { @@ -840,15 +854,6 @@ int main ( int argc, char *argv[] ) // Reload for dynamic part. load_configuration_dynamic ( display ); } - - x11_setup ( display ); - main_loop_source = x11_event_source_new ( display ); - x11_event_source_set_callback ( main_loop_source, main_loop_x11_event_handler ); - - TICK_N ( "X11 Setup " ); - // Sanity check - config_sanity_check ( display ); - TICK_N ( "Config sanity check" ); // Dump. // catch help request if ( find_arg ( "-h" ) >= 0 || find_arg ( "-help" ) >= 0 || find_arg ( "--help" ) >= 0 ) { @@ -863,9 +868,12 @@ int main ( int argc, char *argv[] ) config_parse_xresources_theme_dump (); exit ( EXIT_SUCCESS ); } - // Parse the keybindings. - parse_keys_abe (); - TICK_N ( "Parse ABE" ); + + x11_setup ( display ); + main_loop_source = x11_event_source_new ( display ); + x11_event_source_set_callback ( main_loop_source, main_loop_x11_event_handler ); + + TICK_N ( "X11 Setup " ); rofi_view_workers_initialize (); diff --git a/source/view.c b/source/view.c index 9c51fbfe..2d554a29 100644 --- a/source/view.c +++ b/source/view.c @@ -1628,7 +1628,6 @@ RofiViewState *rofi_view_create ( Mode *sw, } static void __error_dialog_event_loop ( RofiViewState *state, XEvent *ev ) { - printf ( "Event\n" ); // Handle event. if ( ev->type == Expose ) { while ( XCheckTypedEvent ( display, Expose, ev ) ) { @@ -1689,7 +1688,6 @@ void rofi_view_error_dialog ( const char *msg, int markup ) XWindowAttributes attr; if ( main_window == None || XGetWindowAttributes ( display, main_window, &attr ) == 0 ) { main_window = __create_window ( display, MENU_NORMAL ); - printf ( "new window\n" ); } rofi_view_calculate_window_and_element_width ( state ); @@ -1711,18 +1709,10 @@ void rofi_view_error_dialog ( const char *msg, int markup ) XMapRaised ( display, main_window ); if ( sncontext != NULL ) { -// sn_launchee_context_complete ( sncontext ); + sn_launchee_context_complete ( sncontext ); } - printf ( "start\n" ); rofi_view_set_active ( state ); - //rofi_view_queue_redraw(); main_loop_x11_event_handler ( NULL ); - //while ( !rofi_view_get_completed ( state ) ) { - // printf("main loop: %d\n", g_main_context_is_owner(g_main_context_default())); - // g_main_context_iteration ( NULL, TRUE ); - //} - //rofi_view_set_active ( NULL ); - //rofi_view_free ( state ); } void rofi_view_cleanup () |