mirror of
https://github.com/davatorium/rofi.git
synced 2025-03-10 17:06:37 -04:00
Full mainloop madness
This commit is contained in:
parent
4eb3fd1da3
commit
6e3bb506de
6 changed files with 37 additions and 39 deletions
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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 ();
|
||||
|
||||
|
|
|
@ -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 ()
|
||||
|
|
Loading…
Add table
Reference in a new issue