Give up and quit rofi after failed to grab keyboard in <5 sec.

This commit is contained in:
Dave Davenport 2017-01-09 08:17:16 +01:00
parent 713d41f619
commit 78916c6a94

View file

@ -587,28 +587,28 @@ unsigned int lazy_grab_retry_count_pt = 0;
static gboolean lazy_grab_pointer ( G_GNUC_UNUSED gpointer data ) static gboolean lazy_grab_pointer ( G_GNUC_UNUSED gpointer data )
{ {
// After 5 sec. // After 5 sec.
if ( lazy_grab_retry_count_kb > ( 5 * 1000 ) ) { if ( lazy_grab_retry_count_pt > ( 5 * 1000 ) ) {
fprintf ( stderr, "Failed to grab keyboard after %u times. Giving up.\n", lazy_grab_retry_count_kb ); fprintf ( stderr, "Failed to grab pointer after %u times. Giving up.\n", lazy_grab_retry_count_pt );
g_main_loop_quit ( main_loop );
return G_SOURCE_REMOVE; return G_SOURCE_REMOVE;
} }
if ( take_pointer ( xcb_stuff_get_root_window ( xcb ), 0 ) ) { if ( take_pointer ( xcb_stuff_get_root_window ( xcb ), 0 ) ) {
return G_SOURCE_REMOVE; return G_SOURCE_REMOVE;
} }
lazy_grab_retry_count_kb++; lazy_grab_retry_count_pt++;
return G_SOURCE_CONTINUE; return G_SOURCE_CONTINUE;
} }
static gboolean lazy_grab_keyboard ( G_GNUC_UNUSED gpointer data ) static gboolean lazy_grab_keyboard ( G_GNUC_UNUSED gpointer data )
{ {
// After 5 sec. // After 5 sec.
if ( lazy_grab_retry_count_pt > ( 5 * 1000 ) ) { if ( lazy_grab_retry_count_kb > ( 5 * 1000 ) ) {
fprintf ( stderr, "Failed to grab pointer after %u times. Giving up.\n", lazy_grab_retry_count_pt ); fprintf ( stderr, "Failed to grab keyboard after %u times. Giving up.\n", lazy_grab_retry_count_kb );
g_main_loop_quit ( main_loop );
return G_SOURCE_REMOVE; return G_SOURCE_REMOVE;
} }
if ( take_keyboard ( xcb_stuff_get_root_window ( xcb ), 0 ) ) { if ( take_keyboard ( xcb_stuff_get_root_window ( xcb ), 0 ) ) {
return G_SOURCE_REMOVE; return G_SOURCE_REMOVE;
} }
lazy_grab_retry_count_pt++; lazy_grab_retry_count_kb ++;
return G_SOURCE_CONTINUE; return G_SOURCE_CONTINUE;
} }