summaryrefslogtreecommitdiffstats
path: root/source/x11-helper.c
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2017-01-06 11:00:27 +0100
committerDave Davenport <qball@gmpclient.org>2017-01-06 11:00:27 +0100
commit051be0cfe6ae0ca2a81db7c772d0ac67e1c756eb (patch)
treed51c80bb6323ead3eb2f0d9b5dd1c1402171eb0b /source/x11-helper.c
parent129d96928a644005b51ed2661566712c7f02ed87 (diff)
Change keyboard grabbing behaviour, if you fail, continue running and try in background to get them.
Diffstat (limited to 'source/x11-helper.c')
-rw-r--r--source/x11-helper.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/source/x11-helper.c b/source/x11-helper.c
index b3022678..1c909922 100644
--- a/source/x11-helper.c
+++ b/source/x11-helper.c
@@ -515,9 +515,10 @@ int monitor_active ( workarea *mon )
monitor_dimensions ( 0, 0, mon );
return FALSE;
}
-int take_pointer ( xcb_window_t w )
+int take_pointer ( xcb_window_t w, int iters )
{
- for ( int i = 0; i < 500; i++ ) {
+ int i = 0;
+ while ( TRUE ) {
if ( xcb_connection_has_error ( xcb->connection ) ) {
fprintf ( stderr, "Connection has error\n" );
exit ( EXIT_FAILURE );
@@ -532,14 +533,17 @@ int take_pointer ( xcb_window_t w )
}
free ( r );
}
+ if ( (++i) > iters ){
+ break;
+ }
usleep ( 1000 );
}
- fprintf ( stderr, "Failed to grab pointer.\n" );
return 0;
}
-int take_keyboard ( xcb_window_t w )
+int take_keyboard ( xcb_window_t w, int iters )
{
- for ( int i = 0; i < 500; i++ ) {
+ int i = 0;
+ while ( TRUE ) {
if ( xcb_connection_has_error ( xcb->connection ) ) {
fprintf ( stderr, "Connection has error\n" );
exit ( EXIT_FAILURE );
@@ -555,9 +559,11 @@ int take_keyboard ( xcb_window_t w )
}
free ( r );
}
+ if ( (++i) > iters ){
+ break;
+ }
usleep ( 1000 );
}
-
return 0;
}