summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2016-02-19 19:50:48 +0100
committerDave Davenport <qball@gmpclient.org>2016-02-19 19:50:48 +0100
commit6e3bb506de081362d71dc097273fbe954f651056 (patch)
treee38dd0ba4a0b95eb850e3a4decb1c7f9302f0153 /source
parent4eb3fd1da33e91ad76efe1508702de50daf0df34 (diff)
Full mainloop madness
Diffstat (limited to 'source')
-rw-r--r--source/dialogs/dmenu.c1
-rw-r--r--source/helper.c5
-rw-r--r--source/rofi.c38
-rw-r--r--source/view.c12
4 files changed, 27 insertions, 29 deletions
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 ()